philip
philip

Reputation: 365

refresh desktop using batch

I need to refresh the desktop ussing batch is this possible?

I have found the following VBscript that refreshes the containing window however, the desktop needs to be refreahed and its not the containing window

anyways around this?

Set WSHShell = CreateObject("WScript.Shell")

WshShell.SendKeys "{F5}"

thx-

Upvotes: 10

Views: 43592

Answers (5)

Metalhead1247
Metalhead1247

Reputation: 1978

Try this

     @echo off
     taskkill /fi "imagename eq explorer.exe" /f
     CD /d %userprofile%\AppData\Local
     DEL IconCache.db /a
     START explorer.exe

Upvotes: 1

Dr. belisarius
Dr. belisarius

Reputation: 61016

You may try this:

rundll32 user32.dll,UpdatePerUserSystemParameters  

Or this:

ie4uinit.exe -ClearIconCache

It is, however, version dependent.

Upvotes: 7

Riccardo La Marca
Riccardo La Marca

Reputation: 895

@echo off
setlocal EnableExtensions DisableDelayedExpansion
ie4uinit.exe -show
endlocal

Upvotes: 4

NiNiX
NiNiX

Reputation: 51

On Win7 this can be done by calling the function "SHChangeNotify" from "shell32.dll". The problem is that AFAIK this function can't be successfully loaded using "rundll32.exe", so instead use a program that can do it.


Compiled EXE

Use this CLI Refresh Tool from sepago website (32/64 bit images available for download)

AHK (AutoHotKey)

DllCall("Shell32\SHChangeNotify", UInt, 0x08000000, UInt, 0, UIntP, 0, UIntP, 0)

AutoIt

DllCall("shell32.dll", "none", "SHChangeNotify", "long", 0x8000000, "uint", BitOR(0x0, 0x1000), "ptr", 0, "ptr", 0)

Upvotes: 5

aphoria
aphoria

Reputation: 20179

Does it have to be strictly native commands?

If you can use AutoIt, you can use the following script:

WinActivate("Program Manager") 
Send("{F5}")

EDIT

This works on XP. I have not tried it on Vista or 7.

Upvotes: 1

Related Questions