Uninstall multiple versions of a package in one script
I have a script designed as follows:
- Verify - process "myprog.exe" is running
- On success launch $(KACE_SYS_DIR)\msiexec.exe” with params “/X{prog GUID} /qn /norestart”.
- (on success continued) launch Launch “$(KACE_APP_DIR)\runkbot.exe” with params “4 0
This works great, but I found that I have in many cases two or three slightly different versions of the program where the GUID for each is different. I find that I cannot add multiple msiexec uninstall commands because when the first one returns the error "This can only be run for installed....." then the second msiexec uninstall command does not run.
I would like the option to be able to uninstall several versions in one script.
Answers (2)
An example of using it in vbs:
set Installer=CreateObject("WindowsInstaller.Installer")
Set shell = CreateObject("WScript.Shell")
if Installer.ProductState(productcode) = 5 then
strRun="msiexec /x " & productcode & " /qn"
error_code = shell.Run(strRun,1,True)
end if
Note: Create an array of product codes to be uninstalled and parse the array passing the "productcode" to above code.
Comments:
-
Thanks - JordanNolan 11 years ago
Hi,
You can either have some error control logic added in the script so that you can log the error in a txt or log file and contuine with the other uninstallation in case of any failures
Sumit
Comments:
-
Your script should be altered to test for the product's installed state. Check MSDN for details of the 'WindowsInstaller.Installer object model. From memory, the property is 'ProductState'. - anonymous_9363 11 years ago
-
OK, so the only way I can do it is to create a VBScript script rather than using the built in KACE wizard. - JordanNolan 11 years ago