It seems this week is Bad Windows Developer Week for me.
Do you remember that unnamed software package that forced me to create some crappy code to convert UTF-8 to ASCII7? Well, I do need to upgrade it. And plan on letting SCCM do most of the heavy lifting.
Now, sensible developers will make their upgrade package uninstall the old one by itself. Or maybe installed the packages using wmic so we can query them
and uninstall them
And then there are certain software installers that laugh at standards and place their packages wherever they feel like. In a previous article we talked about how to find how to uninstall those packages, so let's apply that knowledge here.
For this article we will create a windows batch file to uninstall the program. In a future article we will do the same using powershell. The command we will use to look into the registry is, surprisingly enough, reg query which needs to know the path in the registry
C:\Users\raub\dev> reg query "HKLM\software\Wow6432Node\Microsoft\Win dows\CurrentVersion\Uninstall\Careless Client 12.3.4_r3" /v UninstallString HKEY_LOCAL_MACHINE\software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\ Careless Client version 12.3.4 r3 UninstallString REG_SZ "C:\Windows\unins000.exe" C:\Users\raub\dev>
Here is what it looks like in a batch file:
@echo off set _uninst_string=reg query "HKEY_LOCAL_MACHINE\software\Wow6432Node\Microsoft\ Windows\CurrentVersion\Uninstall\Careless Client version 12.3.4_r3" /v UninstallString for /f "tokens=3" %%R in ('%_uninst_string% ^| find "C:"') do (set pickles=%%R) rem pickles here is the command. To run it we might want to do something like start /wait %pickles% /SILENT
Note: The set _uninst_string line ends at UninstallString; I just split it into 3 lines to make it easier to read it.
No comments:
Post a Comment