简体   繁体   English

如何使用 NSIS 安装程序重新启动 explorer.exe?

[英]How do I restart explorer.exe with an NSIS installer?

Running the following (hacky) code will gracefully shut down explorer.exe, but re-opens it as a window (not the taskbar).运行以下(hacky)代码将正常关闭 explorer.exe,但将其作为窗口(而不是任务栏)重新打开。

FindWindow $R0 "Shell_TrayWnd"
SendMessage $R0 0x5B4 0 0
Exec "explorer"

However, if I type "explorer" from a cmd window, it opens the taskbar just fine.但是,如果我从 cmd 窗口键入“explorer”,它会很好地打开任务栏。

Someone is bound to ask "Why do you want to kill explorer.exe?"肯定有人会问“为什么要杀explorer.exe?” -- to these people, I say, "shell extensions :|" ——对这些人,我说,“shell 扩展:|”

You can try adding a Sleep before the Exec call.您可以尝试在 Exec 调用之前添加睡眠。 (Explorer calls undocumented shell functions to register itself as Progman+Taskbar, if the old explorer process still exists this call will fail) (Explorer 调用未记录的 shell 函数将自己注册为 Progman+Taskbar,如果旧的 explorer 进程仍然存在,此调用将失败)

There are of course other problems.当然还有其他问题。 There can be other applications that also have your extension loaded or even another Explorer if you are registered under HKCR/HKLM.如果您在 HKCR/HKLM 下注册,则可能还有其他应用程序也加载了您的扩展程序,甚至是另一个资源管理器。

I want to refresh desktop icon after installed app, so I try to restart explorer with exec bat file in nsis, But it doesn't work(sometime it just pop explorer windows, and toolbar disappear).我想在安装应用程序后刷新桌面图标,所以我尝试在 nsis 中使用 exec bat 文件重新启动资源管理器,但它不起作用(有时它只是弹出资源管理器窗口,工具栏消失)。 Finally I find the plug-in( https://nsis.sourceforge.io/NsRestartExplorer_plug-in ), that solve my problem.最后我找到了解决我问题的插件( https://nsis.sourceforge.io/NsRestartExplorer_plug-in )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM