VBScript to Refresh the Desktop

I've been searching the web to find code to refresh a desktop from within a login script, however no code seems to work, any ideas?
LVL 1
BarkersITAsked:
Who is Participating?
 
DarkoLordCommented:
Set shell = CreateObject("WScript.Shell")
shell.SendKeys "{F5}"
0
 
DarkoLordCommented:
What do you mean by refreshing the desktop?
0
 
BarkersITAuthor Commented:
pressing the F5 key
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
RobSampsonCommented:
Hi, try this code:
'==========
Set objShell = CreateObject("Shell.Application")
Set objDesktop = objShell.NameSpace(0)
objDesktop.Self.InvokeVerb "R&efresh"
'==========

Regards,

Rob.
0
 
BarkersITAuthor Commented:
Reply to Darrkolord, that code is good for a refresh, but refreshes the folder I run the script from, which makes sense.

reply ro robSampson, I'm not sure if the code does refresh the desktop as it doesnt flicker as one might expect, what are your thoughts

Thanks Gents
0
 
DarkoLordCommented:
Hi,

I think it should work if your logon scripts run hidden.

What are you trying to refresh, actually? Icons, wallpaper?
0
 
RobSampsonCommented:
Hi, I thought about DarkoLord's F5 method, and came to the conclusion that we need to activate the Desktop somehow.

I then thought that we could just use the "Show Desktop" feature of windows, which normally resides in the Quick Launch bar.  If it's not there, it can be created.....it's just a text file with certain commands.

And, from what I can tell, by clicking Show Desktop, this appears to "flash" the screen as well, possibly refreshing the icons.  If not, uncomment the sendkeys line, and see if that works:
'===========
Option Explicit
Dim objShell, objNetwork, strUserName, strCommand
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
strUserName = objNetwork.UserName
strCommand = "C:\Documents and Settings\" & strUserName & "\Application Data\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf"
objShell.Run """" & strCommand& """", 1, False
objShell.SendKeys "{F5}"
Set objNetwork = Nothing
Set objShell = Nothing
WScript.Quit
'============

Regards,

Rob.
0
 
DarkoLordCommented:
As an addition to the script above, you can use

objShell.SpecialFolders("AppData")

instead of hardcoded path to the Application Data folder, so the script looks like:

'===========
Option Explicit
Dim objShell, strCommand
Set objShell = CreateObject("WScript.Shell")
strCommand = objShell.SpecialFolders("AppData") & "\Microsoft\Internet Explorer\Quick Launch\Show Desktop.scf"
objShell.Run """" & strCommand & """", 1, False
objShell.SendKeys "{F5}"
Set objShell = Nothing
WScript.Quit
'============
0
 
RobSampsonCommented:
BarkersIT, hello again.

I need to ask you a question, completely off topic here, but I am stumped.
In this question:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_22655937.html

You have a tool called EnableDellWOL.exe

Can you please advise me where you get this from?  I would like to use it in my environment, but I cannot find it.

Thanks,

Rob.
0
 
RobSampsonCommented:
BarkersIT, did our latest code help you accomplish this?

And, if you could....let me know about EnableDellWOL??

Thanks,

Rob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.