问题
I'm using Microsoft Visual Studio Installer Projects for my Hybrid Widndows Forms/WPF project. I need to make sure the user has closed the Application (an older version), if active, before the installer can proceed, can this be possible with a Visual Studio Installer Project?
All I've seen so far is that the installer adds by default a dependency to .NET Framework and it won't run unless the dependency is installed first.
回答1:
UPDATE: Windows Installer-Avoid FileinUse dialog box when Installing a package for a list of possible, alternative options in addition to RestartManager support.
RestartManager: The RestartManager feature of MSI is designed to allow your application to gracefully shut down and restart itself during an installation process: How do I add support for Windows Restart Manager to my application? (Advanced Installer)
In essence: The whole idea is basically to prefer restarting applications rather than restarting the OS. To that end:
- Your application calls
RegisterApplicationRestart()
with a command line specified for its eventual restart - it "signs up" for restart management. - Your application watches for
WM_QUERYENDSESSION
messages and shuts down gracefully saving data in an appropriate way when told to do so. - Then RestartManager can restart the application when finished installing (restart can be disabled).
Importance: Just to state the obvious: rebooting a knowledge workers PC is a big deal, and this is why you should really add this RestartManager support to your application. It helps enormously for large scale deployment where you might target 16000 PCs. Also avoid setting REINSTALLMODE to amus (force overwrite) - which can trigger unnecessary reboot prompts. P.S: Make sure your QA guys understand and know how to test the functionality / scenario.
Links:
- How does Windows Installer close an application during uninstall?
- Windows Installer-Avoid FileinUse dialog box when Installing a package
- In-use files not updated by MSI-installer (Visual Studio Installer project)
- https://media.flexera.com/documents/minimizing_reboots_on_vista_systems.pdf
来源:https://stackoverflow.com/questions/54871192/adding-launch-conditions-to-microsoft-visual-studio-installer-projects-check-ap