Refresh desktop with a batch (no "Sendkeys F5")

Trial4life

New member
Local time
7:29 AM
Messages
5
Hi,
I'm not an expert in Windows scripts and programming, but Googling around I've found this code to refresh the desktop/active folder:

Code:
set oWSH = wscript.CreateObject("Wscript.Shell")
Hme = "Home - Microsoft Internet Explorer"
oWSH.appActivate(Hme)
wscript.sleep 1000
oWSH.appActivate(hme)
oWSH.SendKeys "{F5}"

The problem is that the desktop (or the folder) must be the active window; for exaple, if I launch the command from a shortcut on the taskbar, the desktop won't be active and it won't refresh (unless I click on the desktop in less than one second); I could increase the wscript.sleep to have more time to click on the desktop, but it won't be comfortable then.

Is there another smarter way to refresh the desktop?

Thanks in advice.
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 7
Press the F5 key on your keyboard yourself? Tho I don't understand the requirements.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Alienware Aurora ALX R4
OS
Windows 10 Pro (x64)
CPU
Intel Core i7-3930K (3.2GHz - 4.5GHz)
Motherboard
Alienware Aurora-R4 x79
Memory
4x Samsung 4GB PC3-12800 DDR3 (16GB 1600MHz)
Graphics Card(s)
Nvidia Geforce GTX 690
Sound Card
SteelSeries Siberia Elite
Monitor(s) Displays
Dell UltraSharp U3011
Screen Resolution
2560x1600
Hard Drives
Samsung 850 Pro 256 GB, Seagate 1TB Desktop Hybrid HDD, 2x Western Digital 4TB Green HDD
PSU
875W Some Dell PSU <.<
Case
Alienware Aurora ALX
Cooling
Custom Liquid Cooling (EK CPU & GPU blocks) dual EK 480RAD
Keyboard
Logitech G710+ Mechanical
Mouse
Logitech G700s
Internet Speed
Verizon Fios (50 mbps average)
Other Info
Server: Intel NUC D54250WYK: i5-4250U, 16GB, 256 GB mSATA, Windows Server 2012 R2
No... I'd like to automate the action, so I don't have to press the key!

(This is a part of another script that toggles hidden files visualization)
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 7
set it up with task scheduler
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dude Build
OS
Windows 10 Pro X64
CPU
Intel(R) Core(TM) i5-3570K CPU OC@ 4.5GHZ Turbo
Motherboard
MSI Z77A-G45 Gaming
Memory
8.00 GB DDR3 1600Mhz
Graphics Card(s)
MSI Gaming X GTX 1070
Sound Card
Realtek High Definition
Monitor(s) Displays
Dell S23O9W, HP L1710
Screen Resolution
DELL-1920 x 1080 HP-1280 x1024
Hard Drives
Crucial m4 256 SSD, WD 7200RPM 500GB WD 1TB
PSU
Seasonic X650 GOLD
Case
Zalman Z12
Cooling
Antec Kuhler 920
Keyboard
Logitech
Mouse
MSI DS100 Interceptor
Internet Speed
50 down and 5 up
Antivirus
MSE
Browser
Chrome, IE 11
Other Info
Logitech X-620 Speakers
Back
Top