Solved

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

Posted on 2013-02-05
6
973 Views
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.
0
Comment
Question by:ddantes
[X]
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
6 Comments
 
LVL 16

Accepted Solution

by:
choward16980 earned 250 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"
Wscript.Quit
0
 
LVL 16

Expert Comment

by:choward16980
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..
0
 

Author Closing Comment

by:ddantes
ID: 38860565
Very nice, thank you!
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:ddantes
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?
0
 
LVL 16

Expert Comment

by:choward16980
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.
0
 

Author Comment

by:ddantes
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.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

728 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