Skip to content

Instantly share code, notes, and snippets.

@usvi
Created December 1, 2020 18:25
Show Gist options
  • Save usvi/f7aa6f9087797a4b956f6b9c1bdf6578 to your computer and use it in GitHub Desktop.
Save usvi/f7aa6f9087797a4b956f6b9c1bdf6578 to your computer and use it in GitHub Desktop.
RemoveOSCHeck.vbs
' name this file as RemoveOSCHeck.vbs
' This script can be used to remove operating system version checks (2000, xp, vista, 7)
' or architecture checks used for (32-bit x86 or 64-bit x64 systems)
' that are part of an MSI installer. To use drag an MSI file to RemoveOSCHeck.vbs icon.
Option Explicit
Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1
Dim argNum, argCount:argCount = Wscript.Arguments.Count
If (argCount < 1) Then
Wscript.Echo "Please supply the name of the msi file to be modified."
Wscript.Quit 1
End If
' Scan arguments for valid SQL keyword and to determine if any update operations
Dim openMode : openMode = msiOpenDatabaseModeReadOnly
openMode = msiOpenDatabaseModeTransact
' Connect to Windows installer object
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
' Open database
Dim databasePath:databasePath = Wscript.Arguments(0)
Dim database : Set database = installer.OpenDatabase(databasePath, openMode) : CheckError
' Process SQL statements and delete the crap out of this installer!
Dim query, view, record, message, rowData, columnCount, delim, column
Set view = database.OpenView("Delete from LaunchCondition") : CheckError
view.Execute
wscript.echo "Launch Conditions Removed"
Set view = database.OpenView("Delete from InstallExecuteSequence where Action='OnCheckSilentInstall'")
view.Execute
wscript.echo "OnCheckSilentInstall step removed"
Set view = database.OpenView("Delete from Property where Property = 'ISSETUPDRIVEN'")
view.Execute
wscript.echo "Property ISSETUPDRIVEN removed"
Set view = database.OpenView("INSERT INTO Property (Property,Value) VALUES ('ISSETUPDRIVEN',1)")
view.Execute
wscript.echo "Property ISSETUPDRIVEN added"
database.Commit
Wscript.Quit 0
Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbLf & errRec.FormatText
End If
Fail message
End Sub
Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment