Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4058
  • Last Modified:

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?
0
BarkersIT
Asked:
BarkersIT
  • 4
  • 4
  • 2
4 Solutions
 
DarkoLordCommented:
What do you mean by refreshing the desktop?
0
 
BarkersITAuthor Commented:
pressing the F5 key
0
 
DarkoLordCommented:
Set shell = CreateObject("WScript.Shell")
shell.SendKeys "{F5}"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now