prompt to reboot computer after installation compl

2019-08-10 19:49发布

问题:

I am currently adding a deployment project to my C# solution which installs a windows service and I have been trying to find a property that will make the installer prompt the user to reboot the system once installation has completed. I would prefer to simply set a property rather than create a small application that I run at the end of the install. if there is any code to restart then where i'll use this code in installer class or elsewhere?

回答1:

If you use a MSI-based installer (which would be the case if you're using a VS setup project), setting REBOOT=Force should do the trick.

Under normal circumstances, though, the installer will itself detect if a reboot is needed: if you're not currently getting a reboot prompt, that's a good indication your service should work just fine without that reboot.

You may be able to extend your setup logic to start the service after installing it (and also to launch any auto-start GUI components if required). That's much friendlier than forcing a reboot, and you'll do your bit to help Windows get rid of its "you moved your mouse, please reboot" image problem...


Edit (December 2011) @IdentityCrisisUK: see HOW TO: Control System Restarts in a Setup Project That You Created by Using Visual Studio .NET for the exact steps involved in setting the REBOOT variable. Use of Orca is required -- not sure why that has "already been ruled out", as it's a trivial postbuild step...



回答2:

Use the REBOOT Property of WIX to restart prompt in the Product.wxs file of your Setup. Syntax is :-

<Property Id="REBOOT" Value="Force"></Property>