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


  1. Posts : 5
    Windows 7
       #1

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


    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


  2. Posts : 5,642
    Windows 10 Pro (x64)
       #2

    Press the F5 key on your keyboard yourself? Tho I don't understand the requirements.
      My Computer


  3. Posts : 5
    Windows 7
    Thread Starter
       #3

    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


  4. Posts : 5,915
    Windows 10 Pro X64
       #4

    set it up with task scheduler
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:16.
Find Us