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
Your program is a macro program and, like all macro programs, it is fragile.
You can never be sure that the keystrokes are issued in the right context
and any number of conditions can disturb your plans.
In your case the code most likely fails to work because you're issuing the
F5 keystroke in a different context than the one you're thinking. Preceding
F5 with Alt+Tab might help. However, you might also find that the behaviour
of Alt+Tab is slightly different under Windows 7 than under WinXP. Just
because your macro works fine under WinXP does not mean that it will work
under Windows 7. As I said, macros are fragile and must be avoided if you
want a robust environment.
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);
------------------------------------------