Deployment Solution

 View Only
  • 1.  Exit code with a task script editing the registry

    Posted Jun 13, 2014 09:34 AM

    I have the data below setup in a task script, choosing Command Script for the task script. Altiris runs the script and comes back with a Last Status = Failure with Exit Code 1. I see that exit code 1 could mean many different things but which one is bringing up the code 1? I recently added the redirect and log file to each line. But that did not help me, the log files are blank.

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    @ECHO OFF
    ECHO Removal of registry keys. Post-Migration of e-mail

    ECHO 1. HKCU\Software\Novell
    reg delete "HKEY_CURRENT_USER\Software\Novell" /f  >> c:\reg1.log

    ECHO 2. HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Novell GroupWise
    reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Novell GroupWise" /f >> c:\reg2.log

    ECHO 3. HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Novell Default Settings
    reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Novell Default Settings" /f >> c:\reg3.log

    EXIT

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

     

     



  • 2.  RE: Exit code with a task script editing the registry

    Posted Jun 13, 2014 10:51 AM

    To capture errors in the log file you need to add 2>&1 to the end of each redirect to redirect the Standard Error output ('2') to Standard Output ('1') which you have already redirected to the log file.

    So /f >> c:\reg3.log is actually read by the command interpreter as /f 1 >> c:\reg3.log and you need to amend it to  /f >> c:\reg3.log 2>&1.

    Make sure you run the script in the User's context as you're editing HKCU keys.
     



  • 3.  RE: Exit code with a task script editing the registry

    Posted Jun 19, 2014 09:16 AM

    Sorry it took me a while to get back to you.

    That worked, but it only gives me the results of the 'reg delete' lines. I was looking for something that would give more detail for example: no permissions, etc.

     

    I may add '1' as a success code instead. The registry data I need to remove is getting removed. But sometimes the SMA is showing a failure when in reality it has done exactly what it needed to do.



  • 4.  RE: Exit code with a task script editing the registry

    Posted Jun 19, 2014 07:49 PM

    It probably returns a '1' if the reg keys don't exist. I'd expect the log file to show if there was a failure due to permissions.
     



  • 5.  RE: Exit code with a task script editing the registry

    Posted Jun 20, 2014 08:54 AM

    Hey MJammer, what platform are you running this against? This could be a limitation of UAC in newer windows platforms. It seems you are also blindly deleting reg keys and if they are not present, then you might receive an error 1 as a result.  I would sugest checking for the existance of keys before deleting them and going from there... let me know if this helps. :)