cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Reboot System after installation completes in Chained MSI also known as Multi-package Transaction

How to Reboot System after installation completes in Chained MSI also known as Multi-package Transaction

Summary

Discussion and code snippet to facilitate reboot in a Chained MSI

Synopsis

Calling ScheduleReboot from a multi-package transaction is not supported. Therefore you will have to use custom code to facilitate a system reboot after the Chained MSI runs. One way to accomplish this is to create a custom action and associate the custom code to the "OK" or "Finish" button on the setup complete success dialog. In this situation the code is executed when the dialog is presented (which implies successful install) and is based on the button click.

Discussion

A couple of programmatic approaches to author a reboot are below. These are InstallScript and VBScript examples:

InstallScript
#include "ifx.h"

export prototype RebootCA(HWND);

function RebootCA(hMSI)
    
begin

    MsiSetMode( hMSI, MSIRUNMODE_REBOOTNOW, TRUE );

end;


VBScript from - The System Administration Scripting Guide, part of the Windows .NET Server Resource Kit.
strComputer = "atl-dc-01"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
    ObjOperatingSystem.Reboot()
Next







Additional Information

Microsoft documentation references for Multi-Package transactions:

Multiple-Package Installations

Windows Installer 4.5 Transaction Enhancements: Multi Package Transaction
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Jul 18, 2018 09:17 PM
Updated by: