Script to open a folder, refresh the view, and close the folder on Windows startup

Posted on 2013-02-05
Medium Priority
Last Modified: 2013-02-06
My Windows 7 Professional SP-1 system has a number of shared drives which appear in My Computer as physical drives, but they are actually TrueCrypt volumes residing in a NAS.  When the system is rebooted, these volumes are mounted, and attributes for sharing and permissions are applied automatically.  However, the first time My Computer is opened, the sharing icons are not apparent until the view is refreshed.  I would like to automate this refresh process on startup.  But I don't want to do it by closing and restarting explorer.exe, because doing so removes customized desktop icon caption colors, and also removes several icons from the notification area.   So, on startup, I would like to run a batch file which opens, refreshes, and closes the folder "My Computer."  Thank you.
Question by:ddantes
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 16

Accepted Solution

choward16980 earned 1000 total points
ID: 38858278
Paste the code below the line into notepad and save as run.vbs
Run to test
If good, add to startup folder

Locate startup folder:
Under start button->all programs)->startup  
Right click startup folder and select open

Worked like a charm for me:

Set ShObj = CreateObject("wscript.shell")
Set WshShell = WScript.CreateObject("WScript.Shell")
ShObj.run "explorer.exe /root,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
Wscript.Sleep 500
WshShell.SendKeys "%v"
Wscript.Sleep 500
WshShell.SendKeys "r"
Wscript.Sleep 500
WshShell.SendKeys "r"
Wscript.Sleep 500
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 500
WshShell.SendKeys "%F"
WshShell.SendKeys "c"
LVL 16

Expert Comment

ID: 38858279
PS.  You can remove some of the sleep commands to speed up.  JUst make sure to test. You may also need to lengthen some if computer is sluggish on boot..

Author Closing Comment

ID: 38860565
Very nice, thank you!
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!


Author Comment

ID: 38861208
I may have jumped the gun by closing this question after one test.  The refresh is inconsistent with this script.  I'll try increasing the sleep times.  Meanwhile, is there a way to make the performance more reliable?
LVL 16

Expert Comment

ID: 38861353
Increase all the sleep commands to 1500 and see if that atleast shows you where the program is crapping out.  If it isn't opening my computer, you may already have an explorer window open, which might cause an issue.

Author Comment

ID: 38861507
Screenshot of My Computer, after vb script refreshes the window, and before it closes the windowScreenshot of My Computer, after script has run completelyThank you.  Increasing the sleep commands allowed me to observe the performance of the script, which appeared to do what it is intended to do.  A screenshot of My Computer, just before the script closes the window, shows that the drives in question (J:, P: and V:) are all shared, as expected.  But just afterwards, if I open My Computer on the desktop, the "shared drive" icons are missing from those drives, until I manually refresh the window.  These two My Computer windows have slightly different settings, but I don't understand why the sharing attribute isn't displayed, regardless of that.  

To resolve this, the VB script was edited, targeting a shortcut to the My Computer folder on the desktop, instead of the folder itself.  Why this was successful, I don't understand.

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
Introduction to Processes
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question