Uninstall an .exe before installing an .msi only if the exe exists
I have been asked to have an msi package uninstall an exe before
installing itself. The problem is that the uninstall requires a reboot
and this causes a failed install in SMS.
I have been attempting to have the uninstall as a separate package and
set this uninstall as a dependency of the MSI. This does not appear to
work as I am unable to get the uninstall command line working in SMS.
Here is the command line:
cmd /C if exist "C:\Program Files\Zone Labs\Integrity
Client\zauninst.exe" "C:\Program Files\Zone Labs\Integrity
Client\zauninst.exe" /s /noreboot /pwinst "XXXXXXXXXXXXX"
Also, if the uninstall has to be run from a BAT / CMD rather than just
a command line it can not appear in the advertised programs list on
users workstations as it uninstalls the corporate firewall.
I have tried without cmd /c but if exist does not appear to work on its
own (beginning with 'if exist').
Does anybody have any suggestions?
installing itself. The problem is that the uninstall requires a reboot
and this causes a failed install in SMS.
I have been attempting to have the uninstall as a separate package and
set this uninstall as a dependency of the MSI. This does not appear to
work as I am unable to get the uninstall command line working in SMS.
Here is the command line:
cmd /C if exist "C:\Program Files\Zone Labs\Integrity
Client\zauninst.exe" "C:\Program Files\Zone Labs\Integrity
Client\zauninst.exe" /s /noreboot /pwinst "XXXXXXXXXXXXX"
Also, if the uninstall has to be run from a BAT / CMD rather than just
a command line it can not appear in the advertised programs list on
users workstations as it uninstalls the corporate firewall.
I have tried without cmd /c but if exist does not appear to work on its
own (beginning with 'if exist').
Does anybody have any suggestions?
0 Comments
[ + ] Show comments
Answers (6)
Please log in to answer
Posted by:
WiseUser
18 years ago
Posted by:
Bladerun
18 years ago
Posted by:
Flintstone
18 years ago
The task can not be killed as the exe is a service controlled by a virtual device driver (Corporate Firewall).
This is a complete package that needs to be uninstalled along with all its registry entries.
The reason I am not using my package to uninstall is because the uninstall requires a reboot. If a package reboots itself then this is detected by SMS as a failed install (SMS must reboot as the end of the install / uninstall). Thus the uninstall needs to be its own package so this can be run and rebooted, then the install run and rebooted (That is why I need to send the command line via SMS).
This is a complete package that needs to be uninstalled along with all its registry entries.
The reason I am not using my package to uninstall is because the uninstall requires a reboot. If a package reboots itself then this is detected by SMS as a failed install (SMS must reboot as the end of the install / uninstall). Thus the uninstall needs to be its own package so this can be run and rebooted, then the install run and rebooted (That is why I need to send the command line via SMS).
Posted by:
WiseUser
18 years ago
How about something like this:
On Error Resume Next
Const sMYEXE = "%ProgramFiles%\Zone Labs\Integrity Client\zauninst.exe"
Const sMSIEXEC = "%SystemRoot%\System32\Msiexec.exe /qb /i "
Const sMYMSI = "WhatEver.msi"
Set oWsh = CreateObject("Wscript.Shell")
sCurrDir = Replace(Wscript.ScriptFullName, Wscript.ScriptName, "")
oWsh.Run sMYEXE & " /s /noreboot /pwinst " & Chr(34) & "XXXXXXXXXXXXX" & Chr(34), 5, True
iReturn = oWsh.Run(sMSIEXEC & Chr(34) & sCurrDir & sMYMSI & Chr(34), 5, True)
Wscript.Quit(iReturn)
I obviously haven't tested this, so there may be some bugs. But this method should work.
Remember to specify "wscript.exe" as the executable for the "vbs" script (in SMS) if you decide to try it.
Const sMYEXE = "%ProgramFiles%\Zone Labs\Integrity Client\zauninst.exe"
Const sMSIEXEC = "%SystemRoot%\System32\Msiexec.exe /qb /i "
Const sMYMSI = "WhatEver.msi"
Set oWsh = CreateObject("Wscript.Shell")
sCurrDir = Replace(Wscript.ScriptFullName, Wscript.ScriptName, "")
oWsh.Run sMYEXE & " /s /noreboot /pwinst " & Chr(34) & "XXXXXXXXXXXXX" & Chr(34), 5, True
iReturn = oWsh.Run(sMSIEXEC & Chr(34) & sCurrDir & sMYMSI & Chr(34), 5, True)
Wscript.Quit(iReturn)
I obviously haven't tested this, so there may be some bugs. But this method should work.
Remember to specify "wscript.exe" as the executable for the "vbs" script (in SMS) if you decide to try it.
Posted by:
Flintstone
18 years ago
Thanks for that but this still does not work ... this is what I have done so far:
I created the following script:
Script Name: ZAUNINST.VBS
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
WSHShell.Run""".\zauninst.exe"" /s /noreboot /pwinst ""XXXXXXXXXX""", 1, true
Wscript.Quit(0)
Returning 0 at the end sends 0 (Success) to SMS.
I then put zauninst.exe and zauninst.vbs on the distribution point and use wscript.exe zauninst.vbs as the command line.
The reason I am not using a drive letter is because then you would need to specify in SMS that the program requires a drive letter instead of a UNC path ... if you set the requirement of a drive letter it is not possible to have the application download.
The script runs fine from the command line if I copy the programs to any directory on the local machine and run it.
Does anybody else have any suggestions?
I created the following script:
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
WSHShell.Run""".\zauninst.exe"" /s /noreboot /pwinst ""XXXXXXXXXX""", 1, true
Wscript.Quit(0)
Returning 0 at the end sends 0 (Success) to SMS.
I then put zauninst.exe and zauninst.vbs on the distribution point and use wscript.exe zauninst.vbs as the command line.
The reason I am not using a drive letter is because then you would need to specify in SMS that the program requires a drive letter instead of a UNC path ... if you set the requirement of a drive letter it is not possible to have the application download.
The script runs fine from the command line if I copy the programs to any directory on the local machine and run it.
Does anybody else have any suggestions?
Posted by:
WiseUser
18 years ago
Sorry I forgot you for a while...Here's some ammendments to your script (since mine wasn't good enough):[;)]
On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
sCurrentDir = Replace(Wscript.ScriptFullName, Wscript.ScriptName, "")
iRet = WSHShell.Run(Chr(34) & sCurrentDir & "zauninst.exe" & Chr(34) &_
" /s /noreboot /pwinst " & Chr(34) & "XXXXXXXXXX" & Chr(34), 1, true)
Wscript.Quit(iRet)
Why would you hard-code a return code of 0? How would you know if it worked?
On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
sCurrentDir = Replace(Wscript.ScriptFullName, Wscript.ScriptName, "")
iRet = WSHShell.Run(Chr(34) & sCurrentDir & "zauninst.exe" & Chr(34) &_
" /s /noreboot /pwinst " & Chr(34) & "XXXXXXXXXX" & Chr(34), 1, true)
Wscript.Quit(iRet)
Why would you hard-code a return code of 0? How would you know if it worked?
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.