karoljay Posted December 13, 2015 Report post Posted December 13, 2015 I created an application in SCCM, which is initiated by a batch script - it launches MRT security scan - The computer on which I run the application is scanned successfully, the MRT also creates a success log but in the end in Software Center the application is visible as failed. The application is in "installing" state untill the scan is finished, when the actions are finished it fails - it does not time out as the timeout is set to arround 500 minutes. What I thought of is adding "exit /b 0" to give SCCM the "error 0" exit code - unfortunately no success. The batch file has in it: %SYSTEMROOT%\System32\mrt.exe /F:Y /Q for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I set datetime=%datetime:~0,4%-%datetime:~4,2%-%datetime:~6,2%_%datetime:~8,2%-%datetime:~10,2%-%datetime:~12,2% echo f | xcopy /f /y "%SYSTEMROOT%\Debug\"mrt.log "\\servername\log_folder\"%datetime%-%computername%scan.log exit /b 0 Now when I look at the script - maybe I should put the MRT script in one batch and create a 2nd batch which would call the MRT scan script and on the end of this batch I should have the exit /b 0 ? What do you think? Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted December 13, 2015 Report post Posted December 13, 2015 You problem will likely be your xcopy. Remember that CM12 runs a local system account, which likely doesn't have access to the network share. Quote Share this post Link to post Share on other sites More sharing options...
karoljay Posted December 14, 2015 Report post Posted December 14, 2015 Actually I made the share available for all users and the script does everything it needs to do including the copy process, it only shows failed status in Software Center - which is confusing for end users and new service desk staff. Quote Share this post Link to post Share on other sites More sharing options...
GarthMJ Posted December 14, 2015 Report post Posted December 14, 2015 But Remember I said local system account, That is a computer account and not a true user. Quote Share this post Link to post Share on other sites More sharing options...
YPCC Posted December 21, 2015 Report post Posted December 21, 2015 2 things. Is this a "application" deployment or a "package" deployment. If applcation, then the result is based on the outcome of the "detection method" and not a exit code. You could put exit 0 a thousand times but software center will still report an error. If you are deploying as a "package" then exit 0 should work fine. Garth is right in saying sccm uses the local system account. The solution for this is very easy. Add a "net use" command to your script just before you access the share. No drive letter required! Your script should look like: %SYSTEMROOT%\System32\mrt.exe /F:Y /Q for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I set datetime=%datetime:~0,4%-%datetime:~4,2%-%datetime:~6,2%_%datetime:~8,2%-%datetime:~10,2%-%datetime:~12,2% echo f | xcopy /f /y "%SYSTEMROOT%\Debug\"mrt.log Net use "\\servername\log_folder" "\\servername\log_folder\"%datetime%-%computername%scan.log exit /b 0 Net use is required to create a temporary mapping to your share. Without it, sccm will nlt be able to access your share UNLESS you run the script using user credentials Quote Share this post Link to post Share on other sites More sharing options...
karoljay Posted January 7, 2016 Report post Posted January 7, 2016 Thank you both for your help! I needed to apply a quick fix to get this working and I created a package with the "exit /b 0" at the end. YPCC, yes this was an application - to be honest I don't have that much experience yet with creating applications from scripts and not from msi, so definitely I made a mistake, most probably with the detection method. I just put there some random file name as my understanding is that if sccm doesn't find the file the application can run - right? OK - when I wrote the above sentence I just realized, where the problem is , after the installation the random file just isn't there and this is why Software Center shows as failed - please correct me if I'm wrong. BTW - there was no net use command previously and the logs were saved on the file share --> "\\servername\log_folder\" Happy New Year! Quote Share this post Link to post Share on other sites More sharing options...