无需重新启动即可清除 Windows“运行”对话框历史记录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/134748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:18:34  来源:igfitidea点击:

Clearing the Windows "Run" dialog history without rebooting

windowsregistrywindows-explorerprivacy

提问by stormlash

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

我目前正在开发一个程序,以立即清除出现在 Windows开始->运行对话框中的先前运行命令的列表。通过删除HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU键来清除此列表的过程有据可查;但是,在这些更改生效之前,似乎有必要执行以下操作之一:

  1. Restart the computer
  2. Select Start-> Shut down, and then select Cancel.
  1. 重新启动计算机
  2. 选择开始->关机,然后选择取消

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.

这些都不是我想要完成的任务的理想选择:#1 对用户极具破坏性,#2 似乎需要额外的用户交互。

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, withoutrequiring any further action on their part (such as using the "Shut Down" -> "Cancel" trick in #2 above) or forcing a reboot.

有谁知道如何在不需要任何用户交互的情况下立即(并以编程方式)强制重新加载此信息,同时最大限度地减少对用户其他活动的干扰我希望在执行我的程序后立即清除用户的运行历史记录,无需他们采取任何进一步的操作(例如使用上面 #2 中的“关闭”->“取消”技巧)或强制重启.

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 Downand then Cancel?

或者,从不同的角度解决问题:单击开始->关机->取消时,Windows 资源管理器会重新加载 RunMUI 键。 有没有办法强制类似的重新加载而无需用户选择Shut Down然后Cancel

Things I have already tried:

我已经尝试过的事情:

  • Monitoring the explorer.exe status using procmonwhile selecting Shutdownand 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 RegFlushKeycall 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.
  • 使用procmon监视 explorer.exe 状态,同时选择ShutdownCancel。我看到资源管理器写入 RunMRU 键,但无法确定触发此操作的原因。
  • 沿着“无需重新启动即可重新加载 runmru”的路线进行了大量 Google 搜索。大多数结果仍然推荐上面的方法#1,尽管有一些建议#2。
  • 有限的 MSDN API 考试。该RegFlushKey通话看起来是有希望的,但我没有以前使用过,所以我不知道这是否将适用于不同进程缓存的注册表信息。

Any suggestions or other information would be greatly appreciated.

任何建议或其他信息将不胜感激。

回答by stormlash

Have you tried ccleaner?

你试过 ccleaner 吗?

http://www.ccleaner.com/

http://www.ccleaner.com/

回答by csauve

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.

据我所知,它依赖于托管开始菜单/任务栏/桌面的 explorer.exe 进程被关闭和重新打开。我知道没有“干净”的方法可以做到这一点。

If you reallyneed to do this without user interaction, you need to close allexplorer.exe processes and relaunch one.

如果您确实需要在没有用户交互的情况下执行此操作,则需要关闭所有explorer.exe 进程并重新启动一个。

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

这是一个基本的 C# 程序来做到这一点;

  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.

请注意,这将关闭所有打开的“Windows 资源管理器”窗口,之后可能会也可能不会打开额外的“Windows 资源管理器”。

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

我刚刚在 Windows XP 32 位上进行了测试,它确实清除了运行命令缓存。

回答by Alex B

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

不是您问题的完整答案,但我确实从PC Mag 的这篇文章中找到了第三种触发清除运行命令的方法。

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

杀掉explorer.exe再重启也会清除注册表修改后的运行列表。

回答by Jonathan C Dickinson

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.

您可能会尝试寻找图标缓存刷新 API 或其他 API,如果它们具有您正在寻找的副作用,我不会太惊讶。

回答by Saif Khan

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?

我见过它实际工作的实例,即使 F5 键也不起作用?试试这个,ctrl>alt>delete 然后转到任务管理器,进程选项卡...结束 explorer.exe。然后单击文件新任务并键入 explorer.exe,然后检查...是否有效?

回答by Saif Khan

Windows XP

视窗 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
  1. 右键单击任务栏
  2. 属性菜单选项
  3. 开始菜单选项卡
  4. 自定义按钮
  5. 程序窗格
  6. 清晰的列表
  7. 点击确定

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

这将调用一个 Windows API 函数,该函数刷新 explorere.exe 任务栏进程并清除列表(无需编辑注册表)。

回答by Saif Khan

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

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