Correctly Install Software using VBScripts in SCCM 2007

At a client of ours, some of our packagers like to use vbscripts to install software, rather than the .msi itself. Often times this is done for an upgrade project, where we can do some error handling of older versions. For example, we may be deploying Product Version 10, and our user base has a mix of Version 8 and Version 9. A vbscript can determine if version 8 or 9 is installed, and then take the appropriate action to uninstall the old version.

First, make sure that you call your script in the following manner:

cscript.exe //nologo //b “installscript.vbs”

This ensures that the script will run silently without interaction, so if need be it can be installed via an SCCM Task Sequence

Second, I make sure that I am calling the program from the location of the script, so I add do a GetFolder(“.”) and then add that to the prefix of the executable I want to install.

strCurrentFolder = objFSO.GetFolder(“.”)

strInstallString=strCurrentFolder & “\setup.exe /s /v” & Chr(34) & “/qn” & Chr(34)

 

Lastly, there is one problem that does come up. If the install or uninstall is an .exe, you may run into an issue where it is attempting to bring up an ‘Open File – Security Warning’ dialog box. If you run across this dialog box during testing, then add the following lines to your code. Microsoft KB Article 889815 has more information on the specifics

Set WshShell = WScript.CreateObject(“WScript.Shell”)

Set oEnv = WshShell.Environment(“PROCESS”)

oEnv(“SEE_MASK_NOZONECHECKS”) = 1

set objFSO = CreateObject(“Scripting.FileSystemObject”)

strCurrentFolder = objFSO.GetFolder(“.”)

strInstallString=strCurrentFolder & “\setup.exe /s /v” & Chr(34) & “/qn” & Chr(34)

intResult = WshShell.Run (strInstallString,0,true)

If intResult <> 0 then

Call WshShell.LogEvent (4, “Install Failed. Failure Result Code = ” & intResult)

Else

Call WshShell.LogEvent (4, “Install Completed Successfully”)

End If

oEnv.Remove(“SEE_MASK_NOZONECHECKS”)

Leave a comment