Creating Script Wrapper for SCCM

2

How can I create a script wrapper for uninstalling the bellow string asuming that I have the uninst_setup.iss file saved on desktop?

C:\Program Files\InstallShield Installation Information\{4D9CA1B8-5FF5-47A7-8BDF-C37D1F9F55A5}\setup.exe" -l0x9 -removeonly -uninst /s /f1"c:\temp\uninst_setup.iss" /f2"c:\temp\setuppec.log

I can uninstall the string manually if I copy the uninst_setup.iss file to c:\temp then ran the above string in cmd.

I just need help on creating a wrapper to uninstall it on one shot through SCCM.

MaestroIT

Posted 2012-11-02T18:11:24.600

Reputation: 39

Anybody there with an idea please? – MaestroIT – 2012-11-23T15:58:04.727

Answers

0

You shouldn't be using a hardcoded temporary directory. The code below would help you with that. Just take note running this with SCCM (SYSTEM account), the temp directory would resolve to %windir%\temp.

Add a script (eg uninstaller.vbs) with the code below, and the iss file to an SCCM package. Create a program with the following command: cscript.exe uninstaller.vbs

set wsh_shell = createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")

dq = chr(34)
source_path = fso.getparentfoldername(wscript.scriptfullname)
tmp_folder = fso.getSpecialFolder(2)
iss_file = "uninst_setup.iss"
log_file = "setuppec.log"

' Copy the iss file to the temp folder.
fso.copyFile fso.buildPath(source_path, iss_file), tmp_folder, true

' Build the command line
cmd = dq &"C:\Program Files\InstallShield Installation Information\{4D9CA1B8-5FF5-47A7-8BDF-C37D1F9F55A5}\setup.exe" &dq
cmd = cmd &" -l0x9 -removeonly -uninst /s /f1" &dq &fso.buildpath(tmp_folder, iss_file) &dq
cmd = cmd &" /f2" &dq &fso.buildpath(tmp_folder, log_file) &dq

' Run commandline and return exit code to sccm.
wscript.quit wsh_shell.run(cmd, 0, true)

MFT

Posted 2012-11-02T18:11:24.600

Reputation: 542