From: -TNO- on
On Mar 15, 12:02 pm, <-> wrote:
> I've been trying with every sample script I can find on the Net, but the
> double clicking the VBS just flashes the hourglass and then nothing.  All
> these scripts can't be wrong.  It just simply doesn't refresh the desktop.
> I'm doing the Outlook desktop icon thing and if this doesn't work i'm going
> to have to create the less desirable shortcut to .exe because if the icon
> isn't visible immediately then there's no point.
>
> Is there an .EXE utility, or some additional line in the VBS I need to add?
> I've tried two scripts that utilize the sendkeys function, and neither work.
> They don't give an error they just simply don't work.  What is missing?
>
> here is a sample of one of the scripts I used:
>
> Option Explicit
> Dim WSHShell, strDesktop
> Set WSHShell = WScript.CreateObject("WScript.Shell")
> strDesktop = WSHShell.SpecialFolders("Desktop")
> WSHShell.AppActivate strDesktop
> WSHShell.SendKeys "{F5}"
> WScript.Quit

If you wish to refresh the desktop, use the following instead since
SendKeys can "miss":

VBS:
------------------------------------------
Dim oShell : Set oShell = CreateObject("WScript.shell")
oShell.Run "%windir%\System32\RUNDLL32.EXE
user32.dll,UpdatePerUserSystemParameters",1,True
------------------------------------------

Or, in JScript:
------------------------------------------
var oShell = new ActiveXObject("WScript.shell");
oShell.Run("%windir%\\System32\\RUNDLL32.EXE
user32.dll,UpdatePerUserSystemParameters",1,true);
------------------------------------------