/build/static/layout/Breadcrumb_cap_w.png

Running an .msi with an .mst using VB Script

Hello All,

I am trying to run .msi and .mst using vb script, and it doesn't seems to be working as intended. Script calls it but then nothing happens, in the taskbar it shows that there is an .msi listed but it's not really running it. Could someone give me a hand on what is it that I am missing from here. Thanks in advance.


wshshell.Run "MsiExec.exe /i C:\path to\app.msi" "TRANSFORMS=c:\path to\app.mst /qb! /norestart", 0, True

0 Comments   [ + ] Show comments

Answers (5)

Answer Summary:
Try using chr(34) to add quotes to your command where applicable
Posted by: pjgeutjens 12 years ago
Red Belt
2
Try using chr(34) to add quotes to your command where applicable, something like

wshshell.Run "msiexec.exe /i " & chr(34) & "C:\Path to\app.msi" & chr(34) & " TRANSFORMS= " & chr(34) & "C:\path to\app.mst" & chr(34) & " /qb! /norestart", 0, True

Quotes can be specifically tricky in commands when using vbs. To check for errors in the installer itself it might be useful to add logging (/L)

PJ
Posted by: Trinity 12 years ago
Brown Belt
1
You can create a .cmd file that contains the script you want to run then call the .cmd file using
wshshell.Run("\\shareddrive\folder\folder\MyScript.cmd"), 0, True

Or simply add () around your quoted command....
Posted by: manuforti78 12 years ago
Senior Yellow Belt
1
I use the below functions in my scripts, i also find it easier to use the chr(34) as the " to avoid issues with spaces in paths.

I also find this line helpful when running script from current directory where the vbs file is located
sstrPath = Left(Wscript.ScriptFullName,InStrRev(Wscript.ScriptFullName,"\"))
Function RunMSI(strMSI, strMST, strOptions, strTestProperties)
On Error Resume Next
Err.Clear
Dim strMSIlog, strCommand, strFilename, intRet

strMSIlog = sstrMSILogpath & sstrActionName & " - " & sstrInstType & " MSI.log"

If strMST = "" Then
strCommand = " /l* " & chr(34) & strMSIlog & chr(34)
Else
strCommand = " TRANSFORMS=" & chr(34) & sstrPath & strMST & chr(34) & " /l* " & chr(34) & strMSIlog & chr(34)
End If

If Not strOptions = "" Then strCommand = strCommand & " " & strOptions
If sstrTestMode = "True" Then strCommand = strCommand & " " & strTestProperties

If InStr(UCase(strCommand),"/Q") = 0 Then strCommand = strCommand & " /QN "

strCommand = "msiexec /i " & Chr(34) & sstrPath & strMSI & Chr(34) & strCommand
LogInfo ("Running command: " & strCommand)

intRet = sobjShell.Run(strCommand ,1 ,True)

LogInfo ("Result: " & SetReturnText(intRet) & vbCRLF)
strOptions = null
End Function


Sub LogInfo(msg)
Const ForAppending = 8
WScript.Echo msg
Set sobjLogFile = sobjFSO.OpenTextFile(sstrLogFile, ForAppending, True)
sobjLogFile.WriteLine msg
sobjLogFile.Close
Set sobjLogFile = Nothing
End Sub

Function SetReturnText(sRetCode)
' resolve error codes

Select Case sRetCode

Case 0
SetReturnText = "The action completed successfully."
Case 13
SetReturnText = "The data is invalid."
Case 87
SetReturnText = "One of the parameters was invalid."
Case 120
SetReturnText = "A custom action attempted to call a function that cannot be called from custom actions. The function returns the value ERROR_CALL_NOT_IMPLEMENTED. Available beginning with Windows Installer version 3.0."
Case 1259
SetReturnText = "Product may be incompatible with the current operating system."
Case 1601
SetReturnText = "The Windows Installer service could not be accessed. Contact your support personnel to verify that the Windows Installer service is properly registered."
Case 1602
SetReturnText = "The user cancelled the installation."
Case 1603
SetReturnText = "A fatal error occurred during installation."
Case 1604
SetReturnText = "Installation suspended, incomplete."
Case 1605
SetReturnText = "NKNOWN_PRODUCT This action is only valid for products that are currently installed."
Case 1606
SetReturnText = "The feature identifier is not registered."
Case 1607
SetReturnText = "The component identifier is not registered."
Case 1608
SetReturnText = "This is an unknown property."
Case 1609
SetReturnText = "The handle is in an invalid state."
Case 1610
SetReturnText = "The configuration data for this product is corrupt. Contact your support personnel."
Case 1611
SetReturnText = "The component qualifier not present."
Case 1612
SetReturnText = "The installation source for this product is not available. Verify that the source exists and that you can access it."
Case 1613
SetReturnText = "This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service."
Case 1614
SetReturnText = "The product is uninstalled."
Case 1615
SetReturnText = "The SQL query syntax is invalid or unsupported."
Case 1616
SetReturnText = "The record field does not exist."
Case 1618
SetReturnText = "Another installation is already in progress. Complete that installation before proceeding with this install."
Case 1619
SetReturnText = "This installation package could not be opened. Verify that the package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer package."
Case 1620
SetReturnText = "This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package."
Case 1620
SetReturnText = "There was an error starting the Windows Installer service user interface. Contact your support personnel."
Case 1622
SetReturnText = "There was an error opening installation log file. Verify that the specified log file location exists and is writable."
Case 1623
SetReturnText = "This language of this installation package is not supported by your system."
Case 1624
SetReturnText = ",There was an error applying transforms. Verify that the specified transform paths are valid."
Case 1625
SetReturnText = "This installation is forbidden by system policy. Contact your system administrator."
Case 1626
SetReturnText = "The function could not be executed."
Case 1627
SetReturnText = "The function failed during execution."
Case 1628
SetReturnText = "An invalid or unknown table was specified."
Case 1629
SetReturnText = "he data supplied is the wrong type."
Case 1630
SetReturnText = "Data of this type is not supported."
Case 1631
SetReturnText = "he Windows Installer service failed to start. Contact your support personnel."
Case 1632
SetReturnText = "The Temp folder is either full or inaccessible. Verify that the Temp folder exists and that you can write to it."
Case 1633
SetReturnText = "This installation package is not supported on this platform. Contact your application vendor."
Case 1634
SetReturnText = "Component is not used on this machine."
Case 1635
SetReturnText = "This patch package could not be opened. Verify that the patch package exists and is accessible, or contact the application vendor to verify that this is a valid Windows Installer patch package."
Case 1636
SetReturnText = "This patch package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer patch package."
Case 1637
SetReturnText = "This patch package cannot be processed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service."
Case 1638
SetReturnText = "Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs in Control Panel."
Case 1639
SetReturnText = "Invalid command line argument. Consult the Windows Installer SDK for detailed command-line help."
Case 1640
SetReturnText = "Installation from a Terminal Server client session is not permitted for the current user."
Case 1641
SetReturnText = "The installer has initiated a restart. This message is indicative of a success. This error code is not available on Windows Installer version 1.0."
Case 1642
SetReturnText = "The installer cannot install the upgrade patch because the program being upgraded may be missing or the upgrade patch updates a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch."
Case 1643
SetReturnText = "The patch package is not permitted by system policy. This error code is available with Windows Installer versions 2.0."
Case 1644
SetReturnText = "One or more customizations are not permitted by system policy. This error code is available with Windows Installer versions 2.0."
Case 1645
SetReturnText = "Windows Installer does not permit installation from a Remote Desktop Connection. Available beginning with Windows Installer version 2.0 for Windows Server 2003."
Case 1646
SetReturnText = "The patch package is not a removable patch package. Available beginning with Windows Installer version 3.0."
Case 1647
SetReturnText = "The patch is not applied to this product. Available beginning with Windows Installer version 3.0."
Case 1648
SetReturnText = "No valid sequence could be found for the set of patches. Available beginning with Windows Installer version 3.0."
Case 1649
SetReturnText = "Patch removal was disallowed by policy. Available beginning with Windows Installer version 3.0."
Case 1650
SetReturnText = "The XML patch data is invalid. Available beginning with Windows Installer version 3.0."
Case 1651
SetReturnText = "Administrative user failed to apply patch for a per-user managed or a per-machine application that is in advertise state. Available beginning with Windows Installer version 3.0."
Case 3010
SetReturnText = "A restart is required to complete the install. This message is indicative of a success. This does not include installs where the ForceReboot action is run. This error code is not available on Windows Installer version 1.0."
End Select
End Function
Posted by: piyushnasa 12 years ago
Red Belt
1
you should remove the spaces in the path or use chr(34)
Posted by: Mencaliss 12 years ago
Senior Purple Belt
0
Also, you only need to use quotes when your arguments have spaces in them. And you can use double quotes instead of using & Chr(34) &. Easier to read and to formulate.

For example: wshshell.Run "msiexec.exe /i ""C:\Path to\app.msi"" TRANSFORMS=""C:\path to\app.mst"" /qb! /norestart", 0, True

MsgBox can also help to visualise the result of a constructed command.

Hope this help.
 
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