views:

95

answers:

2

Hi,

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?

+1  A: 

You can use ORCA to do this.

See this Microsoft HOW TO article for details:

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

ho1
I checked this link. In this case I or any other developer need to modify the MSI each time with ORCA before delivering the setup to client. Can't I have a one time fix?
Ram
I don't know of any other way, you could go with Oded's answer and add the Shutdown command as a custom action. However, I'd suggest being careful to make sure that you tell the users about this first since they might get a bit upset if you reboot their PC without any prompts...
ho1
A: 

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.

Charles Gargent
@Charles Gargent : Can you please elaborate more on transform for VS setup project?
Ram