Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-02-05
6
Medium Priority
?
1,032 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 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"
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
Independent Software Vendors: 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

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
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…
Suggested Courses

618 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