简体   繁体   中英

Reboot system from Setup project

I am creating a setup project using Visual Studio. I want to reboot the system after the installation completed successfully.

I want it one time effort. I do not want to modify the setup each time using any external tool/ utility before delivering it to client.

Can I tweak the setup project itself?

How Can I do that?

You can use ORCA to do this.

See this Microsoft HOW TO article for details:

http://support.microsoft.com/kb/827020

Try this out:

Create an empty merge module project, in a separate solution and build it. This will create a msm file in the project's Debug or Release folder.

Edit the resulting msm in Orca - setting the REBOOT=Force property as shown here . You'll only have to do this once.

In your main solution, add the merge module to your setup project and build it. Since the merge module was built separately, it will keep the reboot property and merge it into your MSI.

Please dont swhoot me down, but Im not going to answer your specific question, however this is a way to reboot PC after an msi install.

Use WiX instead, it is so much more flexible the the VS built in setup, and there is a plugin for VS.

If you do use WiX this is the code that initiates a reboot.

<InstallExecuteSequence>
  <ScheduleReboot After='InstallFinalize' />
</InstallExecuteSequence>

Alternatively you could create a transform for your VS setup project that only contains the additional entries to initiate the reboot, then anytime you build your project all you need do is apply the transform, you could ship this to customers in a batch file or similar.

ps bear in mind that issuing a shell command as a custom action is not the best way to do it. This will cause the machine to reboot and not return the proper exit code 3010 so if someone is trying to trap the exit code or do a /norestart on the command line the shell command will ignore this.

EDIT Once you have created a msi file open it up with orca and then add the necessary changes to the tables to schedulereboot. Save the changes as a transform then as long as the msi file doesnt change dramatically you can simply apply the transform to the msi everytime you run it.

Personaly I wouldnt want to do this as it is an extra step and you ought to be able to do it in the source.

To add the reboot sequence in orca goto the InstallExecuteSequence table and find the InstallFinalize entry. Add a new entry called ScheduleReboot and enter a number in the sequence column that is 1 greater than the sequence from the InstallFinalize stage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM