3

I need to refresh the desktop and taskbar icons programmatically using a batch file or VBScript.

I found this vbs that hits the usual refresh key, F5:

Set WSHShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{F5}"

but that obviously doens't refresh the icons I mentioned.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Magsood
  • 31
  • 2

1 Answers1

1

Try to refresh Explorer.exe by killing and running it like this way :

Option Explicit
Dim ProcessName : ProcessName = "Explorer.exe"
Refresh(ProcessName)
'*********************************************************************
Sub Refresh(ProcessName)
Kill(ProcessName)
RunIt(ProcessName)
End Sub
'*********************************************************************
Sub Kill(ProcessName)
Dim Ws : Set Ws = CreateObject("Wscript.Shell")
Dim Command : Command = "Taskkill /F /IM "& ProcessName &""
Dim Result : Result = Ws.Run(Command,0,True)
End Sub
'*********************************************************************
Sub RunIt(ProcessName)
Dim Ws : Set Ws = CreateObject("Wscript.Shell")
Dim Result : Result = Ws.Run(ProcessName,1,False)
End Sub
'*********************************************************************
Hackoo
  • 18,337
  • 3
  • 40
  • 70