VBScript 在 Wix 或 MSI 中刷新桌面
我的安装程序在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AppActivate
采用窗口标题或应用程序的进程 ID(但不是文件夹路径!)作为参数。对于 Windows 桌面,Spy++ 报告的窗口标题是“程序管理器”(至少在我的英文 Vista 上)。将脚本更改为以下内容并查看它是否有效: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: