Jump to content
jcasteel

Script to uninstall automate agent via agent uninstaller utility and then reinstall it

Recommended Posts

I have an issue with a bunch of agents that simply will not update without manually connecting to the system, running the uninstaller and then reinstalling. So I'm trying to script this process. I can get the uninstaller to run easily enough, but I can't just script the reinstall because once the agent is uninstalled, the script dies. 

So my next thought was to put it all in a batch file so that it will execute "offline" once the agent is removed. This again works for the uninstaller portion, but reinstalling the .MSI fails and the agent is never deployed. I also put all this into a .VBS and ran via cscript.exe, just to see if it was something specific to the batch file, with the same result, though in both cases if I run it locally it works fine. 

I've yet to determine exactly why the .MSI is failing, as it does appear to attempt to run. I've put a timeout between the two portions to see if it might be an issue with the .MSI running too quickly after the uninstaller is completed, but in both cases the timeout/pause appears to be getting ignored. 

 

Anyone have any suggestions? 

Share this post


Link to post
Share on other sites

"%windir%\system32\WindowsPowerShell\v1.0\powershell.exe" "(new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Reinstall-LTService "


REM To rip and replace to a new server, add this: `-Server https://yourserver.com -LocationID XXX` - Full Documentation is at https://github.com/LabtechConsulting/LabTech-Powershell-Module


GitHub
LabtechConsulting/LabTech-Powershell-Module
This is an attempt to create a comprehensive LT PoSH module. - LabtechConsulting/LabTech-Powershell-Module

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks! Should this be ran as process execute or Shell? 

I've also ran into an issue with it failing to reinstall the service. It retries a few times and ends. Any suggestions? 

Edited by jcasteel

Share this post


Link to post
Share on other sites

We use this uninstall bat when we have issues with uninstalling it normally

@echo off
pause
taskkill /im lttray.exe /f
taskkill /im ltservice /f
taskkill /im ltsvc.exe /f
taskkill /im ltsvcmon.exe /f

regsvr32 /u C:\WINDOWS\LTSvc\wodVPN.dll


sc stop ltservice
sc stop ltsvcmon

sc delete ltservice
sc delete ltsvc
sc delete ltsvcmon

reg delete hklm\software\labtech /f
reg delete hklm\software\wow6432node\labtech /f
reg delete HKEY_CLASSES_ROOT\Installer\Dependencies\{3426921d-9ad5-4237-9145-f15dee7e3004} /f
reg delete HKEY_CLASSES_ROOT\Installer\Dependencies\{3F460D4C-D217-46B4-80B6-B5ED50BD7CF5} /f
reg delete HKEY_CLASSES_ROOT\Installer\Products\C4D064F3712D4B64086B5BDE05DBC75F /f
reg delete HKEY_CURRENT_USER\SOFTWARE\LabTech\Service /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{3426921d-9ad5-4237-9145-f15dee7e3004}
reg delete HKEY_CURRENT_USER\SOFTWARE\LabTech\LabVNC /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Appmgmt\{40bf8c82-ed0d-4f66-b73e-58a3d7ab6582} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{09DF1DCA-C076-498A-8370-AD6F878B6C6A} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{15DD3BF6-5A11-4407-8399-A19AC10C65D0} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{3C198C98-0E27-40E4-972C-FDC656EC30D7} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{459C65ED-AA9C-4CF1-9A24-7685505F919A} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{7BE3886B-0C12-4D87-AC0B-09A5CE4E6BD6} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{7E092B5C-795B-46BC-886A-DFFBBBC9A117} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{9D101D9C-18CC-4E78-8D78-389E48478FCA} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{B0B8CDD6-8AAA-4426-82E9-9455140124A1} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{B1B00A43-7A54-4A0F-B35D-B4334811FAA4} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{BBC521C8-2792-43FE-9C91-CCA7E8ACBCC9} /f
reg delete HKEY_CLASSES_ROOT\CLSID\{C59A1D54-8CD7-4795-AEDD-F6F6E2DE1FE7} /f


echo Deleting keys
call :DELETEKEY 3426921d-9ad5-4237-9145-f15dee7e3004
call :DELETEKEY 3F460D4C-D217-46B4-80B6-B5ED50BD7CF5
call :DELETEKEY 02ff82a3-f67d-4d3f-bc33-26c877c793a7
call :DELETEKEY b5ff5d67-cb77-4a86-8398-d20c2acef43a

echo Deleting agent folder
rmdir /s /q %windir%\ltsvc

echo Agent removed, reboot initiated
goto END

:DELETEKEY
set GUID=%1%
echo Deleting GUID %GUID% ...
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL\{%GUID%} /f
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432NODE\MICROSOFT\WINDOWS\CURRENTVERSION\UNINSTALL\{%GUID%} /f
goto :EOF

:END
pause

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×