Silent MSI Package Installation with Custom Parameters Using VBScript

Nov 20, 2025 · Programming · 12 views · 7.8

Keywords: MSI Installation | Silent Installation | VBScript Scripting | Windows Installer | Automated Deployment

Abstract: This technical paper provides a comprehensive guide to implementing silent installation of MSI packages using VBScript in Windows environments. The article details the use of msiexec command with /quiet and /qn parameters for UI-free installation, and demonstrates how to override custom parameters like installation location and installation type using PROPERTY=value syntax. Complete VBScript implementation including installation status detection, error handling, and logging is presented, offering a complete solution for automated deployment scenarios.

Fundamentals of MSI Silent Installation

Windows Installer (MSI) is Microsoft's standard software installation technology that supports silent installation through the msiexec.exe command-line tool. The core principle of silent installation involves using specific command-line parameters to suppress user interface display while overriding interactive parameters through public property settings.

Silent Installation Parameters Explained

msiexec.exe provides several parameters for controlling installation behavior:

Custom Parameter Override Mechanism

MSI packages expose configurable parameters through public properties. These properties can be set using the PROPERTY=value syntax in the command line. For example, to set installation directory and installation type:

msiexec /i package.msi /qn INSTALLDIR=C:\CustomPath INSTALLLEVEL=100

Where INSTALLDIR property controls installation location and INSTALLLEVEL property controls installation type (typically 100 for minimal installation, 1000 for complete installation).

Complete VBScript Implementation

The following VBScript code demonstrates a complete MSI silent installation workflow, including installation status detection, parameter override, and error handling:

Option Explicit

Dim objShell, objFSO, msiPath, installDir, installType
Dim productCode, isInstalled, returnCode

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Configuration parameters
msiPath = "C:\packages\Foobar.msi"
installDir = "C:\Program Files\CustomFoobar"
installType = "minimal"  ' Options: minimal or full
productCode = "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"  ' Replace with actual product code

' Check if already installed
isInstalled = CheckInstallation(productCode)

If Not isInstalled Then
    ' Build installation command
    Dim installCmd, logPath
    logPath = "C:\logs\foobar_install.log"
    
    installCmd = "msiexec /i " & Chr(34) & msiPath & Chr(34) & " /qn /norestart " & _
                  "/l*v " & Chr(34) & logPath & Chr(34) & " " & _
                  "INSTALLDIR=" & Chr(34) & installDir & Chr(34) & " " & _
                  "INSTALLLEVEL=" & GetInstallLevel(installType)
    
    ' Execute installation
    returnCode = objShell.Run(installCmd, 0, True)
    
    If returnCode = 0 Then
        WScript.Echo "Installation completed successfully"
    Else
        WScript.Echo "Installation failed with return code: " & returnCode
    End If
Else
    WScript.Echo "Software already installed, skipping installation"
End If

Function CheckInstallation(productCode)
    Dim registryPath, objRegistry
    registryPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & productCode
    
    On Error Resume Next
    Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
                              ".\root\default:StdRegProv")
    
    Dim values, valueTypes
    CheckInstallation = (objRegistry.EnumValues(&H80000002, registryPath, values, valueTypes) = 0)
    On Error GoTo 0
End Function

Function GetInstallLevel(installType)
    Select Case LCase(installType)
        Case "minimal"
            GetInstallLevel = "100"
        Case "full"
            GetInstallLevel = "1000"
        Case Else
            GetInstallLevel = "100"  ' Default to minimal installation
    End Select
End Function

Error Handling and Log Analysis

Detailed logging is crucial during silent installation. Using the /l*v parameter generates verbose installation logs for troubleshooting. Common error codes include:

Best Practices Recommendations

In actual deployment scenarios, follow these best practices:

  1. Always validate installation parameters in test environment before production deployment
  2. Use full paths when specifying MSI file and log file locations
  3. Implement comprehensive error handling and rollback mechanisms
  4. Regularly check and update product codes and property names
  5. Consider using group policy or configuration management tools for large-scale deployment

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.