14 Replies Latest reply on Aug 5, 2008 12:22 PM by cambrown28

    Uninstall agent and report status back to Scheduled Task

    Apprentice

      Hi All

       

      LDMS 8.8 SP1.

       

      What I am trying to do is to run the uninstallwinclient.exe in a Scheduled Task and have the status of the task report as Successful. I have tried using the uninstallwinclient.exe in an "Executable Distribution Package" and a "Batch File Distribution Package" but the Scheduled Task just hangs after the agent is removed from the target because the files are no longer there to report the status of the task back to the core.

       

      I have tried using both IF "%ERRORLEVEL%"=="0" EXIT /B %ERRORLEVEL% and IF NOT "%ERRORLEVEL%"=="0" EXIT /B %ERRORLEVEL% but these don't work because they are waiting for the task to finish and by then it is too late, the files to report back are gone.

       

      I am willing to assume that the uninstallwinclient.exe is going to work if it starts executing so I don't need to wait for it to finish to set the status of the task to Successful.

       

      Does anyone have any creative ideas on how this could be achieved (if it is at all possible)?

       

      Cam

        • 1. Re: Uninstall agent and report status back to Scheduled Task
          MarXtar ITSMMVPGroup

           

          Part question, part suggestion.

           

           

          Why are you doing this? Are you removing LANDesk completely or preparing for some other installation?

           

           

          That aside, I would suggest that you stop trying to use LANDesk to report the status and instead go to something else such as using your errorlevel to then output a success flag file that can then be picked up via another method.  If you have a recent enough version to use run as user, or perhaps your script launches the uninstall under the credentials of a domain admin with write privilidges to another share where you can put a flag file or output the machine name to a text file listing all machines that are successful and one that lists machines that were unsuccessful. LDDiscover might also be a good tool to use if you want to target via push as it will work independent of the presence of the landesk agent.

           

           

          There are ways to report back status to the core, but realistically they would require too much of the agent to remain on the machine or access to a share containing the files.  Better to use an independent mechanism since you are deliberately removing LANDesk.

           

           

          Mark Star - http://www.marxtar.com

           

           

          Home of Power State Notifier & Wake-On-WAN for LANDesk

           

           

          • 2. Re: Uninstall agent and report status back to Scheduled Task
            Apprentice

            Hi Mark

             

            Why am I doing this? We have a project where a customer wants to use LANDesk Process Manager (LPM) to both install and uninstall the LDMS agent. I have the install process working fine, it is just the uninstall workflow that I am trying to configure.

             

            I tried lddiscover passing uninstallwinclient.exe as a command (as you suggested) and it works well, although there is still no way (that I can see) to differentiate between when lddiscover runs (and works) and when it runs (and fails due to not being able to access a machine for example). Using the "Execute Program" action in LPM returns a value of 0 because lddiscover ran, LPM has no idea that lddiscover could not access the client and therefore could not run the uninstallwinclient.exe program.

             

            I have very little experience with writing scripts. Do you have an example of a script that could create the flag file you mentioned above?

             

            Cam

            • 3. Re: Uninstall agent and report status back to Scheduled Task
              MarXtar ITSMMVPGroup

              Hmm. Interesting way of using LPM. Therefore a suggestion and a question.

               

              Suggestion:

               

              You are pretty much there with your errorlevel script, you could simply have its action on a 0 errorlevel being to echo "removal success: >
              server\share\uninstall\%hostname%.txt (check the variable)

               

              And do a similar thing for a failed uninstall. Perhaps you could then pick the presence of the file via LPM and delete it once you have registered success.

               

              Difficult bit is making sure your batch file has the rights to create that file.

               

              Question:

               

              Why and under what conditions are they trying to use LPM to do this? This would more often be seen as something done as a machine or user level gpo or login script. What event/condition are they using to determine whether to install or uninstall?

               

              Mark Star - http://www.marxtar.com

               

              Home of Power State Notifer & Wake-On-WAN for LANDesk

              • 4. Re: Uninstall agent and report status back to Scheduled Task
                Apprentice

                We will be creating a portal (connected to LPM via a listener) for them to request the install/uninstall of an agent.

                 

                I will try your suggestions and let you know what I discover.

                 

                Thanks for your help.

                 

                Cam

                • 5. Re: Uninstall agent and report status back to Scheduled Task
                  Apprentice

                   

                  Here is what I have so far. This does not create the file %computername%.txt. It does copy the file to C:\temp but then stops. Any idea why?

                   

                   

                  {

                   

                  @ECHO ON

                   

                   

                  :: Copy uninstall file to asset

                  copy
                  referenceldms\packages\uninstallwinclient.exe c:\temp\uninstallwinclient.exe

                   

                   

                  IF "%ERRORLEVEL%"="0" (GOTO success) ELSE (GOTO fail)

                   

                   

                  :success

                  ECHO The file was successfully copied > c:\temp\%computername%.txt

                   

                   

                  :fail

                  ECHO The file does not exist > c:\temp\%computername%.txt

                   

                   

                  :end}

                   

                   

                  • 6. Re: Uninstall agent and report status back to Scheduled Task
                    MarXtar ITSMMVPGroup

                     

                    Change = to ==

                     

                     

                    This worked for me:

                     

                     

                    if "%errorlevel%"=="0" (GOTO ZERO) ELSE (GOTO NOTZERO)

                     

                     

                    :ZERO

                    Echo It was zero > c:\%computername%.txt

                    GOTO END

                     

                     

                    :NOTZERO

                    Echo It was not zero > c:\%computername%.txt

                    GOTO END

                     

                     

                    :END

                     

                     

                    Mark Star - http://www.marxtar.com/

                     

                     

                    Home of Power State Notifier & Wake-On-WAN for LANDesk

                     

                     

                    • 7. Re: Uninstall agent and report status back to Scheduled Task
                      Rookie

                      You could create a runonce (bat/vbs) key that would execute the uninstall winclient on next reboot. That would report a success that the key was created and files delivered. it would not be immediate however. I am sure something could be scripted to have it run on logoff. The only thing you may have to watch is how long your sdmcache is kept locally. depending on how immediate it happens, you may have to copy it to another directory. Not very likely though. Hope you get a way that works for you, Joe.

                      • 8. Re: Uninstall agent and report status back to Scheduled Task
                        Apprentice

                        Hi Joe

                         

                        I am using your suggestion of a runonce key.

                         

                        If I use the LOCAL_MACHINE runonce key, the uninstallwinclient.exe runs before allowing a user to login (which took a few minutes in my test). This is not really suitable for this customer. If I use the CURRENT_USER runonce key, the uninstallwinclient.exe runs after the user logs in and allows them to continue working while it is running. Much better.

                         

                        However, using the CURRENT_USER runonce key introduces some problems. For it to work, I have to set the Distribution Package to run under the "Current User's Account". This works as long as the user has the permissions to copy the files, edit the registry, etc. This is not always going to be the case.

                         

                        Any ideas how I can put uninstallwinclient.exe in the CURRENT_USER runonce key if the user doesn't have the appropriate permissions?

                         

                        Cam

                        • 9. Re: Uninstall agent and report status back to Scheduled Task
                          MarXtar ITSMMVPGroup

                           

                          Couple of suggestions.

                           

                           

                          First, if you no longer need to see the status of the uninstall (which will happen if you use the runonce option, then also consider instead of using a registry key, just using LPM to add the user to a removal group in AD, saves even trying to do anything via software distribution.

                           

                           

                          As far as getting the correct rights, you  need to go back in time a little and use the NTConfig kit that comes with LANDesk.  This consists of a listener service and a pullcfg program.  These were used to allow installation of the agent by login script when users weren't admins.  Pullcfg is launched on the client and the this asks the listener service running as an admin to remotely connect to the client and launch the install.  The small issue is that it expects the installation program to be called wscfg32.exe.  For this to work, you will need to make a copy of the uninstallwinclient and rename it to wscfg32 and use pullcfg to launch that.

                           

                           

                          The instructions for setting this up are a bit long winded for here but they do exist and will give you the admin rights that you need.

                           

                           

                          Mark Star - http://www.marxtar.com

                           

                           

                          Home of Power State Notifier & Wake-On-WAN for LANDesk

                           

                           

                          1 of 1 people found this helpful
                          • 10. Re: Uninstall agent and report status back to Scheduled Task
                            Tracy Expert

                            You could always just create a batch file that calls uninstallwinclient and sends back the starus of the bat file.

                             

                             

                            -


                            start "Uninstallwinclient" uninstallwinclient.exe /switch1 /switch2

                            -


                             

                             

                            be sure to add uninstallwinclient.exe as an additional file of the bat distribution package.

                             

                            -Tracy

                            • 11. Re: Uninstall agent and report status back to Scheduled Task
                              Apprentice

                              Thanks Mark

                               

                              I will investigate using Pullcfg and see if that works for me.

                               

                              Cam

                              • 12. Re: Uninstall agent and report status back to Scheduled Task
                                Apprentice

                                Hi Tracy

                                 

                                This is what I was trying to do originally but the problem is that the status was never returned because the files that are used to return that staus were removed from the client when uninstallwinclient.exe was run.

                                 

                                Cam

                                • 13. Re: Uninstall agent and report status back to Scheduled Task
                                  Rookie

                                   

                                  you are correct, the process would have to finish before the user got their desktop. You could create a VBS that has a shell run command that does not wait on a return and put that in HKLM\...\runonce. this would write the key without using user credentials but they would still need to have uninstall privelages. the vbs would kick off the install and finish, allowing the logon to continue (maybe, it would need to be tested).

                                   

                                   

                                  • 14. Re: Uninstall agent and report status back to Scheduled Task
                                    Apprentice

                                    Thanks to all for their help.

                                     

                                    The solution I went with was to use psexec to run uninstallwinclient on the remote computers. I was able to pass the computer names to psexec via an LPM field which I could not do using lddiscover.

                                     

                                    Cam