/build/static/layout/Breadcrumb_cap_w.png

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.


0 Comments   [ + ] Show comments

Answers (2)

Posted by: Sujit J 11 years ago
Blue Belt
1

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:
Posted by: sumitsingh1984 11 years ago
Second Degree Green Belt
0

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
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ