0

Is there any good article that explains more about RestartManager and how to make the applications aware and handle the special messages in order to shutdown properly?

I have two applications that are installed with MSI installer build in Visual Studio Setup Project. One of this applications is WPF application and another one is a web API application that is running in Kestrel web server.

This two applications are running in background

When we have another version of the MSI installer, where the PackageCode and ProductCode are updated accordingly as the Version number, when you try yo install the new file the FileInUse window is displayed and the MSI Installer can't shutdown the running applications.

I found out about RestartManager and the Guidelines for applications -> https://learn.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications

But not sure how can I make my application to be aware of the RestartManager and to shutdown when update or uninstall is available.

My applications are installed in windows 10 or higher.

I tried to handle the WM_ENDSESSION message in my WPF application but that didn't worked correctly...

1
  • AFIK the MSI installer is responsible for closing applications. So you should instruct the installer that it should close your applications. WPF app closes itself by default when receives WM_QUERYENDSESSION. Kestrel web server is a console app, so it will receive CTRL_C_EVENT and also close itself by default. So even if you do nothing, the applications will close themselves, however they won't restart. Commented Aug 12, 2024 at 15:36

1 Answer 1

0

Call RegisterApplicationRestart (WM_QUERYENDSESSION is your last chance to call this but you may call it sooner).

What the exact command line should be is up to you, it may be as simple as /restart or if you need to store state information in a specific file, you might need something like /restore "c:\myfolder\appstate.ini". When the restart manager starts your application, it will be launched with the command line parameters you registered.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.