开发者

VBScript to refresh Desktop in Wix or MSI

My installer creates the reg key under HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace which creates an icon on the desktop during install开发者_JS百科ation 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?


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}"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜