2

I need to restart Windows Explorer from my custom installer, but the catch is that I can't simply "kill its process" I need it to close "gracefully" so that it saves its settings.

While doing a search I found out that Windows has this option covered. If you open up the Start menu, then Ctrl+Shift+Right-click on an empty space of the start menu, you'll see a context menu that gives you the "Exit Explorer" command that does exactly what I need.

So I was wondering, is there an API to do that from a program?

ahmd0
  • 16,633
  • 33
  • 137
  • 233
  • Seems complicated to get that right, you know, it might not be the user that is running the installer that owns the desktop. – Albin Sunnanbo Oct 12 '12 at 04:47
  • There may be multiple explorers running under different user acocunts, too. – bdonlan Oct 12 '12 at 04:50
  • @bdonlan: Yes, I need it for the user account that the installer is running under. (Note that this is not an MSI type installer, so no GPO installations will be done with it.) – ahmd0 Oct 12 '12 at 04:56
  • I tried posting WM_QUIT to the main thread of the explorer.exe but it works only in 75% of the time. Otherwise it simply ignores that message. – ahmd0 Oct 12 '12 at 04:57
  • Can I ask why you need to do this? – Aesthete Oct 12 '12 at 05:38
  • @Aesthete: The "asked already" link posted by Theraot below explains it pretty well. – ahmd0 Oct 12 '12 at 05:42

1 Answers1

8

The question of how to mimic the behaviour of "Exit Explorer" has been asked already.

But this is not what the installer should do, instead the installer should use Restart Manager Functions.

You can use it for various things depending on your needs:

  • Log out the user and log in again.
  • Close Explorer.exe and start it again.
  • Close services and start them again.
Community
  • 1
  • 1
Theraot
  • 31,890
  • 5
  • 57
  • 86