8 Replies Latest reply on Jun 23, 2009 11:57 AM by Mach6

    Software uninstall is successful but shows as Failed in console

    Rookie

      This is such a pain in the butt.  I have a software distribution package to UNINSTALL Office 2007.  It removes the software just fine.  Problem is that the setup.exe /uninstall always returns 1641 (rebooting after execution) or 3010 (reboot required).  I been reading about batch files and errorlevels until I am dizzy.  I have tried this over and over with different batch files.  Supposedly, you can write a batch file to check for a certain errorlevel then reset the errorlevel to 0 within the batch so that the batch/distribution package returns 0 to LanDesk.  If LanDesk gets anything other than 0 for a return code, it shows Failed even thought right after that is says "Operation completed successfully.  Device is being rebooted for changes to take effect"

       

      Can anybody help me cut to the chase and figure out how to get the distribution package to return 0 to LanDesk?  I just don't see how it's possible when a reboot is required.  And yes, I have tried all the no reboot options.  It doesn't matter.  Uninstalling Office absolutely requires a reboot.  Sure you can force it not to do so at the end of the uninstall, but you still get the 3010 return code.  So the only way to fix this is to intercept and change the return code on the way back to LanDesk.  Does anyone know how to do this?

        • 1. Re: Software uninstall is successful but shows as Failed in console
          zman Master

          What version are you running with SP? There was a fix in 8.8 SP2 to adress this

           

          CR00010414

          Software Distribution

          Tasks that finish with a "reboot required" status message are shown as "failed" in the Console. This causes the policy to be reapplied. This has been corrected so that SWD treats the MSI return code 3010 (reboot required) as "installation succeeded" with a machine code to show that a reboot was required.

           

          The way I would handle this is a script, Something like this:

           

          • Run the application with a wait and no reboot.
          • Store the return code to a variable.
          • Test the variable for conditions 0= success, 3010 = success, etc...
          • Take appropriate action based on conditions If var = 3010 then reboot, etc...

           

          I would do it in Autoit but Jared has some sample batch in this post http://community.landesk.com/support/message/3639#3639 and you probably already read this one http://community.landesk.com/support/docs/DOC-2320

           

          I would make sure that the delivery method is  reboot id needed. I'm wondering if LANDesk might be getting confused since you have a batch file returning MSI return codes.

           

          Also, when you feel a post is finished, please close it. It helps us to not have to sort through a lot of posts that are closed but not marked as such.

          • 2. Re: Software uninstall is successful but shows as Failed in console
            ahe Expert

            Hello Steve,

             

            a little hint...

             

            AutoIt code fragement:

            
            ; $UninstallString contains your MSI uninstall command line
             
            $code = RunWait($UninstallString, $WorkDir, @SW_HIDE)
            Sleep(10000)
                 If $code Then
                 If $code = 3010 Then
                            ; Make a reboot, for example with shutdown or send a message to the user or LANDesk
                      ; MsgBox(0,"Uninstallation of MS Office", "Successfull uninstallation, a reboot of the workstation is requested.")
                 Else
                            ; MsgBox(0,"Error", "Uninstallation of MS Office not successfull, the error code is: " & $code)
                         SetError(4)
                           Return;
                 EndIf
                 Else
                    ; No reboot necessary, for example with shutdown or send a message to the user or LANDesk
                    ; MsgBox(0,"Uninstallation of MS Office", "Successfull uninstallation!")
                    
                 EndIf
            . . .
            

             

             

             

            As batch fragment:

             

            . . .
            set instlogfile = %temp%\mso2007_uinst.log
            
            start /wait %your_uninstall_commandline% 
            
            Set ResultCode=%ERRORLEVEL%
            if "%ResultCode%"=="0" (
                 >>%instlogfile% echo "Uninstallation successful, no reboot necessary."
                 "%LDMS_LOCAL_DIR:~0,-5%\sdclient.exe" /msg="Uninstallation successful, result code %ResultCode%.")
                 goto END
            ) else (
                 if "%ResultCode%"=="3010" (
                      >>%instlogfile% echo "Uninstallation successful, reboot required, reboot started in some seconds"
                      "%LDMS_LOCAL_DIR:~0,-5%\sdclient.exe" /msg="Uninstallation successful, reboot required, result code %ResultCode%.")
                      goto OK
                 ) else (
                      if "%ResultCode%"=="1641" (
                           >>%instlogfile% echo "Uninstallation successful, reboot after execution, reboot started in some seconds"
                           "%LDMS_LOCAL_DIR:~0,-5%\sdclient.exe" /msg="Uninstallation successful, reboot after execution, result code %ResultCode%.")
                           goto OK
                      ) else (
                           >>%instlogfile% echo "Uninstallation not successful!"
                           "%LDMS_LOCAL_DIR:~0,-5%\sdclient.exe" /msg="Uninstallation not successful, result code %ResultCode%.")
                           exit %ResultCode%
                      )
                 )
            )     
            
            :OK
            shutdown -r -t 10
            goto END
            
            :END
            exit 0
            
            ...

             

            Regards

            Axel

            • 3. Re: Software uninstall is successful but shows as Failed in console
              Rookie

              Thanks for the help so far guys, although I have to say alot of this (script above) is over my head.  This issue is driving me nuts.  I want to solve it.  Here is the batch file I am using.  I am pushing the batch file to the client with "download from source".  I don't know if that makes a difference.  What if I "run from source"?  Anyway,

               

              @ECHO ON

              start /wait \\2003rras\office2007install\setup.exe /uninstall Pror /config \\2003rras\office2007install\uninstallconfig.xml

               

              Set ResultCode=%ERRORLEVEL%
              if "%ResultCode%"=="0" goto END
              if "%ResultCode%"=="3010" goto OK
              if "%ResultCode%"=="1641" goto OK
              exit %ResultCode%

              :OK
              shutdown -r -t 10
              goto END

              :END
              exit 0

               

              I know the result code being returned is 3010.  Everytime with current settings.  When I ran the task, Office was uninstalled and the client machine rebooted in 10 seconds just like it was supposed to, but in the LanDesk Console I still get Status of Failed with "The system rebooted unexpectedly while processing the distribution package.  State of the installation/removal is unknown"

               

              Please help me on this guys.  I don't understand why it is so damn hard to get the batch file to return 0 to LanDesk.  I need to keep it simple, too.

              • 4. Re: Software uninstall is successful but shows as Failed in console
                zman Master

                So what may be happening is that shutdown is running and it never reaches your exit statement in the batch file since it is waiting for shutdown to exit.  As stated above if you use autoitscript you could run the reboot without a wait using run(....).  I don't think you can run a batch file without it waiting for the command to complete.  Maybe sdclient will provide better error returns:

                 

                sdclient.exe /msg="Rebooting."
                sdclient.exe /reboot
                

                 

                in lieu of shutdown.

                • 5. Re: Software uninstall is successful but shows as Failed in console
                  Employee

                  A batch file can launch a process and not wait by using the "start" command.

                   

                  You can change the reboot line to look like this:

                   

                  start shutdown -r -t 10

                  • 6. Re: Software uninstall is successful but shows as Failed in console
                    ahe Expert

                    Hello Steve,

                     

                    as Mach6 and Zman said, you must exit your batch with code "0" (for success) before reboot/shutdown.

                     

                    I've forgotton to add "start" in front of "shutdown"... :-)

                     

                    With the lines

                    "%LDMS_LOCAL_DIR:~0,-5%\sdclient.exe" . . .

                    you can send a message to LANDesk Scheduled Task windows, so you can check what's happen during a installation.

                     

                    About Batch File Distribution Packages

                     

                    In the meantime I prefer the AutoIt solution, it's more flexible and you can create a standard uninstallation function for all apps...

                     

                    I found a bit here: http://www.autoitscript.com/forum/index.php?showtopic=83496&hl=silent%20uninstall&st=0

                     

                    Dim $MyApps[6] = ["App1, App2"]
                    $InstalledAppsCount = 1
                    $Found = 0
                    
                    While 1
                    
                        $SubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $InstalledAppsCount)
                        If @error Then ExitLoop
                        
                        $DisplayName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $SubKey, "DisplayName")
                        $Uninstallstring = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $SubKey, "UninstallString")
                    
                        
                        For $i = 0 To UBound($MyApps)-1
                            If StringInStr($DisplayName, $MyApps[$i]) And StringInStr($Uninstallstring, "msiexec") Then
                    
                                $Found += 1
                                If Not StringInStr($Uninstallstring, "/qb") And Not StringInStr($Uninstallstring, "/qn") Then $Uninstallstring &= " /qb"
                                RunWait(StringReplace($Uninstallstring,"/I{","/X{"),"")
                            EndIf
                        Next
                    
                        $InstalledAppsCount += 1
                    
                    WEnd
                    
                    If Not $Found Then
                        MsgBox(64, "Not Found", "No apps found", 3)
                    EndIf
                    

                     

                    or a other method: (full QuickTime example with send messages to LANDesk: http://www.autoit.de/index.php?page=Thread&threadID=7806)

                     

                    . . .
                    $DPName="QuickTime"
                    ; uninstallation loop of all QuickTime versions
                    do
                        $num=$num+1
                        $key=RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",$num)
                        if @error <> 0 then 
                            $fin=1
                        Else
                            $displayname=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$key,"DisplayName")
                            if (StringLower(stringleft($displayname,stringlen($DPName)))=stringlower($DPName)) then
                                $UninstallString=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$key,"UninstallString")
                                $DisplayVersion=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"&$key,"DisplayVersion")
                                LDEcho ("Uninstall Version "&$DisplayVersion)
                                $code=RunWait("MsiExec.exe /X"&$key & " /qn")
                                Sleep(20000)
                            EndIf
                        EndIf
                    Until $fin
                    . . .
                    
                    

                     

                     

                    Regards

                    Axel

                    • 7. Re: Software uninstall is successful but shows as Failed in console
                      Rookie

                      thanks for all the feedback guys.  i seem to have resolved the issue with alot of your help.  my solution is real simple.

                       

                      here is the batch file

                       

                      @ECHO ON

                      start /wait \\2003rras\office2007install\setup.exe /uninstall Pror /config \\2003rras\office2007install\uninstallconfig.xml

                      Set ResultCode=%ERRORLEVEL%
                      if "%ResultCode%"=="0" goto END
                      if "%ResultCode%"=="3010" goto OK
                      if "%ResultCode%"=="1641" goto OK
                      exit /B %ResultCode%

                       

                      :OK
                      cmd /c
                      goto END

                       

                      :END
                      exit /B 0

                       

                      I have edited the uninstallconfig.xml so that the machine does not boot after uninstall, nor is the user prompted to reboot.  setup.exe exits with return code 1641 or 3010 (this value goes into errorlevel), but cmd /c resets errorlevel to zero before the batch exits.  Finally, LanDesk reports Sucess even though the machine is not rebooted.  And even if it DID reboot, LanDesk would still show Failed without the techniques for resetting errorlevel in batch files.

                       

                      Now, onto the NEXT big challenge in LanDesk.  I have been up all night reading and trying to understand the Patch and Security Manager.  It really makes no sense to me.  It seems like a really convoluted way to keep updated.  Compared to WSUS (which I mastered easily in a few hours) it looks like a huge undertaking.  I have read the BKM.  Still have no clue what I am doing.  So this is my understanding so far.

                       

                      The core server is currently downloading definitions and executable patches for those definitions.  That's what I set it to do.  One thing I noticed is I'm getting a lot of "failed to download data for product XYZ" and "failed to download 123456" where 123456 is a vulnerability definition, I guess.  Is this a concern?  I never like to see failed.  Can someone tell me why that happens?

                       

                      Now, after I have downloaded all these definitions they should go into the scan group.  The scan group lists all vulnerabilities that will be checked on client machines?  Now, my understanding is that once I am ready to scan a client machine the process will only report back what vulnerabilities were found without fixing them.  From the reading it seems like you have to right click on every found vulnerability and choose Repair.  Is this accurate?  What I am interested in is automating this process as much as possible.

                       

                      I like LanDesk, but it seems to me they make updating way more complicated than it needs to be.  In WSUS, it takes me 2 minutes to determine which updates are lacking on any machine.  With LanDesk, I have no clue what has been applied.   Hopefully I'll learn.

                       

                      Mainly, here is what I would like to do.  Set up some kind of task to 1)scan machine for vulnerabilities and 2)download executable/patches from server and 3)install patches all in one run.  There has to be a way to do this just like in WSUS.  Please help.  Thank you.

                      • 8. Re: Software uninstall is successful but shows as Failed in console
                        Employee

                        Hi Steve,

                         

                        I would recommend that you create a new discussion under Security Management for the new question.  With a one question per discussion format you'll usually get better results.

                         

                        LANDesk is a lot more configurable than WSUS, which means that there are a myriad of options.  Once you select how you want to implement your patches it is usually very easy to pull off.  What you are trying to do is not too difficult at all.  Since I don't want to create confusion on this thread for people who might read it later I'll hold off going into more detail until your new discussion thread is created.

                         

                        Also, marking the discussion as Answered will help people in the future who might be trying to find the same solution as you did.

                         

                        Thanks!