Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
409 views
in Technique[技术] by (71.8m points)

installation - Wix Installer Problem: Why does RestartManager mark Service as RMCritical and not RMService

I'm trying to prevent our wix installers from prompting the user for a reboot when uninstalling. Our services are set to be uninstalled and deleted on an uninstall. Unfortunately for us the RestartManager is prompting the user that a reboot will be required during the InstallValidate action. This action occurs well before the StopServices and DeleteServices actions.

Checking the logs, it seems that the RestartManager thinks that our service is a critical process:

"Detected the application with id 1234, friendly name 'abc', service short name 'xyz', of type RmCritical and status 1 holds files[s] in use."

The services are installed and running under the local system account. I'm not sure but I think if RestartManager was returning RmService instead of RmCritical then it wouldnt be prompting for a reboot.

Any help much appreciated.

EDIT: MSDN states that for RMCritical: A system restart is required to complete the installation because a process cannot be shut down. The process cannot be shut down because of the following reasons. The process may be a critical process. The current user may not have permission to shut down the process. The process may belong to the primary installer that started the Restart Manager.

The user does have permission to shut down the services, and the services are not anything to do with msiexec so I can only assume that our service is thought to be a critical process.... but why?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can suppress window's RestartManager by setting the MSI property MSIRESTARTMANAGERCONTROL= "Disable" (see documentation here - http://msdn.microsoft.com/en-us/library/windows/desktop/aa370377(v=vs.85).aspx). The only problem with this approach by itself is that instead of prompting users with a reboot-required dialog, they will see the file-in-use dialog (and be asked to shut down any applications that might be using those files/services). This dialog is displayed during the InstallValidate standard action of the InstallExecute Sequence.

If you want a sneaky way around either of these dialogs you can schedule a custom action before InstallValidate that manually shuts down any running services before the RestartManager has a chance to inspect the system. This does not follow standard MSI practices because normally you would mark a custom action that modifies the system as a 'deferred' action, but MSI doesn't allow any deferred actions to run before InstallValidate. So, you would have to mark the action as 'immediate', but in the code you would go ahead and modify the system by shutting down the services. The drawback here is that there's no such thing as an immediate rollback action, so if your uninstall/upgrade fails and does a rollback the services you stopped will be left in a stopped state. The upside is that users never have to see any additional dialogs during their uninstall/upgrade.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...