VBScript 在 Wix 或 MSI 中刷新桌面

发布于 2024-10-02 11:02:02 字数 742 浏览 1 评论 0原文

我的安装程序在 HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace 下创建 reg 密钥,该密钥在安装过程中在桌面上创建一个图标,但卸载后,该图标会一直保留,直到我按 F5。 所以我用谷歌搜索并从此处找到了它,所以我添加了:

<CustomAction Id="CA_RefreshDesktopVB" Script="vbscript">
<![CDATA[
    Set WSHShell = CreateObject("WScript.Shell") 
    strDesktop = WSHShell.SpecialFolders("Desktop") 
    WSHShell.AppActivate strDesktop
    WSHShell.SendKeys "{F5}"
]]>
</CustomAction>

<InstallExecuteSequence>
...
<Custom Action="CA_RefreshDesktopVB" OnExit="success"/>

但是卸载完成后并没有刷新。是我做错了什么还是这根本超出了 VB 脚本的范围?

My installer creates the reg key under HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace which creates an icon on the desktop during installation but after uninstallation, that icon stays until I press F5.
So I googled and found it from here, so I added :

<CustomAction Id="CA_RefreshDesktopVB" Script="vbscript">
<![CDATA[
    Set WSHShell = CreateObject("WScript.Shell") 
    strDesktop = WSHShell.SpecialFolders("Desktop") 
    WSHShell.AppActivate strDesktop
    WSHShell.SendKeys "{F5}"
]]>
</CustomAction>

<InstallExecuteSequence>
...
<Custom Action="CA_RefreshDesktopVB" OnExit="success"/>

However, it didn't refresh when the uninstallation finished. Did I do something wrong or is this simply beyond VB Script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人生戏 2024-10-09 11:02:02

AppActivate 采用窗口标题或应用程序的进程 ID(但不是文件夹路径!)作为参数。对于 Windows 桌面,Spy++ 报告的窗口标题是“程序管理器”(至少在我的英文 Vista 上)。将脚本更改为以下内容并查看它是否有效:

Set WSHShell = CreateObject("WScript.Shell")
WSHShell.AppActivate "Program Manager"
WSHShell.SendKeys "{F5}"

AppActivate takes either the window title or the application's process ID (but not folder path!) as a parameter. In case of Windows desktop, the window title as reported by Spy++ is "Program Manager" (at least on my English Vista). Change your script to the following and see if it works:

Set WSHShell = CreateObject("WScript.Shell")
WSHShell.AppActivate "Program Manager"
WSHShell.SendKeys "{F5}"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文