views:

1266

answers:

9

I am currently working on a program to immediately clear the list of previously-run-commands which appears in the Windows Start -> Run dialog. The procedure for clearing this list by removing the *HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU* key is well documented; however, before these changes take effect, it seems to be necessary to do one of the following:

  1. Restart the computer
  2. Select Start -> Shut down, and then select Cancel.

Neither of these is ideal for the task I am trying to accomplish: #1 is extremely disruptive to the user, and #2 appears to require additional user interaction.

Does anyone know how to immediately (and programmatically) force a reload of this information without requiring any user interaction, while also minimizing disruption of the user's other activities? I would like for the user's Run history to be cleared out immediately after executing my program, without requiring any further action on their part (such as using the "Shut Down" -> "Cancel" trick in #2 above) or forcing a reboot.

Or, to approach the problem from a different angle: When clicking Start -> Shut Down -> Cancel, Windows Explorer reloads the RunMUI key. Is there a way to force a similar reload without having the user select Shut Down and then Cancel?

Things I have already tried:

  • Monitoring the explorer.exe status using procmon while selecting Shutdown and then Cancel. I see Explorer writing to the RunMRU key, but have not been able to determine what triggers this.
  • Numerous Google searches along the lines of "reload runmru without reboot". Most results still recommend method #1 above, although a few suggest #2.
  • Limited MSDN API examination. The RegFlushKey call appears promising, but I haven't ever used it before, so I don't know if it will apply to registry information cached by different processes.

Any suggestions or other information would be greatly appreciated.

A: 

Not a full answer to your question, but I did find a third way to trigger the clearing of the run command from this article in PC Mag.

Killing explorer.exe and then restarting it will also clear the run list after the registry modification.

Alex B
A: 

HKEY_CURRENT_USER\ Software\ Microsoft\ Windows\ CurrentVersion\ Explorer\ RunMRU\

Saif Khan
Did you even read the question? He knows where the key is, Explorer doesn't refresh it.
Vincent McNabb
Sorry if I upset you mate! Will pay attention nextime around.
Saif Khan
A: 

So, You know the path to registry where this is stored.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU

But you still dont want to delete those entries programmatically?

Prakash
based on what he has said, you can delete them programmatically, but Explorer doesn't bother to reload the list from the registry unless the shutdown dialog is brought up, or the computer is rebooted.
X-Cubed
A: 

I have a nasty hack for you. Show the window programatically, hide it immediately (programatically) and click cancel on it (well, you guessed, programmatically).

You might try looking for the icon cache flush API, or other ones, I wouldn't be too suprised if they had side effects like the one you are looking for.

Jonathan C Dickinson
A: 

I've seen instances where it actually works, even the F5 key doesn't work? Try this, ctrl>alt>delete then go to task manager, processes tab...end explorer.exe. Then click on file new task and type explorer.exe, then check...does that work?

Saif Khan
A: 

Windows XP

  1. Right click on the taskbar
  2. Properties menu option
  3. Start Menu tab
  4. Customize button
  5. Programs pane
  6. Clear List
  7. Click on OK

This calls a Windows API function that refreshes the explorere.exe taskbar process and also clears the list (no need for registry edits).

You got it wrong, he tries to clear the RUNMRU entries not the program shortcut on the Start pane.
Eddy
A: 

Try a reboot. That always work for me.

Angus G
The question is rather clear on that point, "Reboot: extremely disruptive to the user". Its something that he wants to avoid.
mizipzor
+1  A: 

Have you tried ccleaner?

http://www.ccleaner.com/

Mike
A: 

As far as I know, it relies on the explorer.exe process that hosts the start menu/taskbar/desktop being closed and reopened. There is no "clean" way to do this that I am aware of.

If you really need to do this without user interaction, you need to close all explorer.exe processes and relaunch one.

Here's a rudimentary C# program to do that;

  using System.Diagnostics;

  Process[] procs = Process.GetProcessesByName("explorer");
  foreach (Process proc in procs)
  {
    proc.Kill();
  }

  Process.Start("explorer.exe");

Note that this will close all "Windows Explorer" windows open, and may or may not open an additional "Windows Explorer" afterwards.

I just tested that on Windows XP 32bit, and it did indeed clear the Run command cache.

csauve