Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
Redmond desk4 min

Scripting Windows Installer Packages with WSH and COM

Use WSH and the Windows Installer COM automation interface for external package tasks, but do not confuse that workflow with script custom actions, which run inside the installer without WSH.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To inspect or automate a Windows Installer package from a standalone VBScript or JScript, use Windows Script Host (WSH) to create the COM automation object with the ProgID WindowsInstaller.Installer. That workflow is different from a script custom action: the installer runs such actions itself, without WSH, so the WScript object is unavailable. For package customization, first consider public properties or a transform; use script where those mechanisms do not meet the requirement.

Choose the right scripting context

“Windows Installer scripting” can mean two different things. One is an external WSH script that automates Windows Installer through COM. The other is a VBScript or JScript custom action embedded in, or installed for, an MSI package and invoked during installation. The host, available objects, timing, and security constraints differ.

Workflow Who runs the script Windows Script Host objects Typical use
External WSH automation WScript.exe or CScript.exe WSH provides its scripting host object model; the script can create the Installer COM object. Inspect products or databases, run administrative automation, or perform package-related tasks outside an installation.
Installer script custom action Windows Installer during package processing WScript is unavailable. Creating some other WSH model objects may be possible with CreateObject, subject to action type and security restrictions. Perform a package-specific operation during installation when standard actions and package configuration mechanisms are insufficient.

Microsoft states that “The installer runs script custom actions directly and does not use the Windows Script Host.” See its Windows Installer Scripts reference. Do not copy an external WSH script into a custom action assuming that objects such as WScript.Echo or WScript.Arguments will work.

Use the Installer COM automation object from WSH

The automation entry point is an Installer object created with the ProgID WindowsInstaller.Installer. Microsoft describes it as loading automation support and exposing methods and top-level objects. See the Installer object reference and About the Automation Interface.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

WSH supplies two hosts: CScript.exe for command-line execution and WScript.exe for a desktop script host. In VBScript, create a COM object with CreateObject; JScript can use ActiveXObject or WScript.CreateObject. The host choice does not change the Installer ProgID, but it does affect how the script is launched and interacts with the user. Microsoft documents COM use in WSH in Using COM Objects in Windows Script Host.

Minimal VBScript entry point

Set installer = CreateObject("WindowsInstaller.Installer")

This creates the automation object; it is not, by itself, a complete package operation. The next step depends on the task: for example, use a documented automation member to access a product or database, then handle errors and any required inputs explicitly. Launch a saved VBScript with CScript.exe for command-line use or WScript.exe for the desktop host.

What external automation can do

Microsoft’s Windows SDK scripting examples illustrate a range of automation tasks. The examples are reference material, not supported tools or a guarantee that a particular script is appropriate for a current deployment.

  • WiLstPrd.vbs lists products, properties, features, and components.
  • WiImport.vbs and WiExport.vbs import and export files.
  • WiStream.vbs manages binary streams.
  • WiGenXfm.vbs and WiUseXfm.vbs generate and apply a transform.
  • WiRunSQL.vbs executes SQL statements against Installer databases.

The examples require Windows Script Host. Microsoft explicitly says the samples are unsupported and are provided only as potentially useful reference material. See Windows Installer Scripting Examples for the sample descriptions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prefer package configuration mechanisms when they fit

Not every customization needs a script. Windows Installer best-practice guidance recommends public properties and customization transforms for configurable package values. A transform can apply package changes without adding custom script logic; Microsoft refers to Msitran.exe for creating customization transforms. Check the package’s design and the relevant Installer guidance before editing or redistributing it.

Repackaging deserves particular care: a tool that treats Installer configuration data as ordinary files or registry state can misunderstand the package’s own configuration. Use documented package mechanisms where suitable, and reserve custom actions for requirements they genuinely address. Microsoft notes that standard actions are sufficient in most cases; custom actions are intended for specific needs, such as calling functions or deferring work. See Windows Installer Best Practices and Custom Actions.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When a script custom action is necessary

A custom action runs as part of package processing, so its timing and execution context are part of the installation design—not merely a different way to launch a standalone script. Choose the action type and scheduling based on the operation, its relationship to installer transactions, and the privileges and security constraints involved. Consult the custom-action reference for the supported types and sequencing behavior rather than relying on an external script’s assumptions.

Windows Installer documents script custom actions in VBScript and JScript. A 64-bit script custom action must be marked as a 64-bit custom action. Test the package and action in the target environment: legacy examples and references do not establish behavior or support for every current Windows deployment configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A practical decision path

  1. Define the job. If you need to inspect products, query or modify a database, or automate work outside an installation, begin with external WSH automation and the Installer COM object.
  2. Check package-native options. If the change is a configurable value, determine whether a public property or customization transform meets the requirement.
  3. Use a custom action only for an installation-time need. Confirm that standard actions and package configuration cannot do the job, then select an action type appropriate to the required timing and execution conditions.
  4. Match code to its host. External scripts can use WSH; installer-hosted script actions cannot use the WScript object. Review any object creation and security assumptions for the action type.
  5. Validate architecture and environment. Mark a 64-bit script custom action accordingly and test on the Windows versions, package architecture, and deployment conditions that matter to your organization.

Documentation scope and support

The Microsoft Learn pages on scripts, scripting examples, the automation-interface overview, and custom actions were marked updated January 7, 2021. They document the interfaces and workflows described above, but should not be read as a blanket compatibility guarantee for every present-day Windows deployment. The Installer object reference also has page-specific operating-system requirements; verify those requirements against the intended environment. No performance or adoption statistic is established by these technical references.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.