Created
June 30, 2017 14:32
-
-
Save ivanrad/80fb195a04f4f507d3f31d65a6f8b36d to your computer and use it in GitHub Desktop.
MSI schedule reboot (wsh)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @(#) msi_schedule_reboot.js | |
// | |
// Update an MSI so that a reboot action will be required after an install sequence completes. | |
// | |
// (c) Ivan Radanovic, <ivan.radanovic at gmail> | |
// | |
var msi_action = "ScheduleReboot" | |
var msi_condition = "NOT Installed" | |
var msi_sequence = 7000 | |
var msiOpenDatabaseModeTransact = 1 | |
function die(msg) { | |
WScript.StdErr.WriteLine(msg) | |
WScript.Quit(1) | |
} | |
if (WScript.Arguments.Length != 1) | |
die("usage: " + WScript.ScriptName + " <msi_file>") | |
try { | |
installer = WScript.CreateObject("WindowsInstaller.Installer") | |
db = installer.OpenDatabase(WScript.Arguments(0), msiOpenDatabaseModeTransact) | |
sql = "INSERT INTO `InstallExecuteSequence` (`Action`, `Condition`, `Sequence`) VALUES ('" + msi_action + "', '" + msi_condition + "', " + msi_sequence + ")" | |
view = db.OpenView(sql) | |
view.Execute() | |
view.Close() | |
db.Commit() | |
} catch(e) { | |
die("error: " + e.message) | |
} | |
WScript.Quit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment