Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

wix - Windows Installer-Avoid FileinUse dialog box when Installing a package

When ever there is an update patch of files that have to be replaced with the existing files and if one of the files is being used by any of the processes, then a file in use dialog box pops-up.I wanna avoid that dialog box and get that file queued up for installation so that it can be installed at the time of system reboot. I have read that the queuing the files for update at the time of reboot is the inbuilt functionality of windows installer. Can someone suggest me the way to remove that FileInUse Dialog box. I tried setting up the "MsiRMFilesInUse" property to "0" but it didn't work.

Question&Answers:os

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

1 Answer

0 votes
by (71.8m points)

"Short" Answer

Essentially: you could 1) run completely silently (suppresses the files-in-use dialog), 2) shut down locking applications gracefully (application update to allow graceful shutdown - with or without restart manager support), 3) ensure proper service control (if dealing with services), 4) force-kill running processes (the "sledgehammer-approach"), 5) abort setup if locks are detected, 6) require logoff before deployment, 7) install to a new folder for each version (side-by-side install), etc...

Below is a little drill-down of files-in-use issues and the Restart Manager - intended as a quick review for files-in-use and reboot issues.

In terms of your actual problem. I wouldn't mess with the FileInUse dialog(s). It won't really solve your problem. Maybe consider these pointers:

  • Services: If you are installing services and they trigger files-in-use issues, please see section on services towards the bottom to determine if you can improve your setup's logic.
  • Silent Mode: Running your setup in silent mode would be an obvious way to suppress such files-in-use dialogs, but then you have to suppress automatic reboot, or the system will spontaneously reboot without warning. Details below.
  • Policy: Please check if the DisableAutomaticApplicationShutdown policy is enabled on your box / standard PC configuration. See details below.
  • Registry location is: HKLMSoftwarePoliciesMicrosoftWindowsInstaller.
  • I am not sure if enabling this policy will make the files-in-use dialogs disappear.
  • Restart Manager Compliance: Maybe check if you should update your application to heed the design of the Restart Manager feature - to allow for auto-magic and problem free upgrades by applications shutting themselves down gracefully (provided you are dealing with binaries that you can actually change yourself - in other words: you have the source code). Lots of details below.
  • "Setup Overkill": If you deem it safe to kill your application without mercy during upgrades, see section on this below.
  • Graceful Shutdown Custom Action: If you make your application capable of graceful shutdown (restart manager-style), then you can trigger such a shutdown yourself as well (easiest for user context processes) via an immediate mode custom action (in case Restart Manager is disabled by policy - look out for timing and timeout issues though - especially for silent running - "deadlock").
  • Side-By-Side Installation: some details below. Some companies decide to install applications truly side-by-side so there are no file overwrite issues with their new deployments (old versions uninstall may still trigger required reboots though).

I suppose you could also abort the install if locked files are detected, or you could require users to log off before the installation is run - if you have a distribution system.

Please at least skim the rest of the answer for more details and context.


Restart Manager

Your applications and services should be prepared to be shut down by the Restart Manager and save user data and state information that are needed for a clean restart. This requires updates and changes to the application / service to adhere to standards for shutdown and restart of the application.


The Restart Manager: is a new C-style API available beginning with Windows Vista and Windows Server 2008. Restart Manager consists of a single DLL that applications can load to access the Restart Manager API. The idea is that the Restart Manager will auto-magically shut down and restart your applications during installations / updates, by having the application / service follow a set of guidelines:

In essence: The whole idea is basically to prefer restarting applications rather than restarting the OS - and also to avoid reboots in general.. To that end: 1) Your application calls RegisterApplicationRestart() with a command line specified for its eventual restart - it "signs up" for restart management. 2) Your application watches for WM_QUERYENDSESSION messages and shuts down gracefully saving data in an appropriate way when told to do so. 3) Then Restart Manager can restart the application when finished installing (restart can be disabled).

More Technical stuff:


Restart Manager Configuration: There are a number of properties that will affect how the Restart Manager will operate with Windows Installer:

When Restart Manager is used, the MsiRMFilesInUse dialog is used instead of the FileInUse dialog to show a list of applications that have locked files.

N.B! The whole Restart Manager feature can also be disabled by policy:


FileInUse

If you don't have the time or resources to implement proper interoperability with the Restart Manager (which is frankly the only sane thing to spend your resources on at this point in Windows's development), then there are a few things that might be good to know:

  • Silent Install: The first obvious thing to point out is that there will be no FileInUse dialog if you install the setup in silent mode. However, this could trigger a system reboot unless you specify the REBOOT=ReallySuppress property.
  • Services: Do you install services that you do not properly shut down during upgrade? There are built-in MSI constructs to shut down services during upgrades - the Service Control table.
  • Used properly, this ServiceControl feature means you no longer have any problems with service executables triggering a reboot to be replaced (barring shutdown problems in the service itself).
  • This is a built-in MSI constructs and works well when used right. People should not resort to custom actions to install services.
  • Application Support: Beyond interoperability with the Restart Manager, some application - that have files in use - can shut down gracefully when told to do so.
  • Some applications shut down properly when sent a command line, for example App.exe -shutdown, despite not having been written to be interoperable with the Restart Manager. Maybe system tray applications that save no data for the user?
  • This obviously has to be implemented specifically for the application in question - and if you do that, you should use the Restart Manager instead at this point (or additionally, you could have both call the same actual shutdown implementation).
  • "Setup Overkill": some setups are designed to just kill application processes that are open at the time of installation.
  • Not ideal, but it can work for certain types of applications that run in the background (OK, it is nuts, but it is done regularly).
  • Use a custom action or whatever built-in constructs are available in your deployment tool.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...