Reconnect mapped drive script

tourist08
tourist08 used Ask the Experts™
on
Hello I was wondering if anyone could provide me with a script that will connect and reconnect mapped drives on a wireless XP laptop.  The main problem isn't so much on start up but when the laptop goes to sleep and comes back up.  Any other suggestions would be appreciated.  Thanks.  
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NET USE H: \\server\share /persistent:yes

Author

Commented:
Alan White
So if I place a .bat file to run at start up with the persistent:yes option it will continually check to see if the drive is connected?  

Commented:
Here is a vbscript that will do it.  You can add as many drives as you'd like.


Set oNetwork = CreateObject("WScript.Network")
Set oFS = CreateObject("Scripting.FileSystemObject")
If Not oFS.FolderExists("S:\") Then oNetwork.MapNetworkDrive "S:", "\\server\share"

Open in new window

Commented:
Or place a reconnect bat file in Startup as suggested and place a shortcut on the desktop for the user to use.
Most Valuable Expert 2011
Top Expert 2011

Commented:
The drive should only disconnect, not unmap on wakeup....

If you double click the drive, it should reconnect with no problem.... Is this not the case?

Or do you have an app reliant on a "drive letter mapping"?

Author

Commented:
tbarkdull
yeah I did place a shortcut for them to click on but they wanted something that didn't involve the user.

josika
How does that vbscript work?  and where would I put it?

Commented:
Modify it for the proper drive letter, server name and shared path then save it as a .vbs file and just double click it.

Author

Commented:
Any way I can get something that will run when the laptop comes out of standby, instead of having the user click a file?

Author

Commented:
johnb6767
Yes there is an app the relies on the mapped drives.  
Most Valuable Expert 2011
Top Expert 2011

Commented:
Any chance the app can be modified to a UNC path, perhaps via the registry, or .INI/Settings file?

Triggering an event from a wake event, is not easy.....Cant just use a standard Startup Entry, like you would for a logon.....

Author

Commented:
johnb6767
What do you mean by a unc path via registry?  

Author

Commented:
goraek
thanks for the site but my problem is not how to connect it's keeping the connection with a wireless card after it goes to standby then comes back up without having any user interaction to reconnect.  
"Yes there is an app the relies on the mapped drives."

Is this app running all the time or does the user initiate it?  I was wondering if you could make a batch file that would reconnect the drive and then launch the app and put a shortcut to this batch file instead of the normal one?

Author

Commented:
Alan white
the user initiates the app usually when they log into xp then just leaves it running all day.  But when the computer is inactive and goes to standby and comes back up the drives don't reconnect and the programs freezes.  
And this app cannot be configured with a UNC path instead of a drive letter?

Author

Commented:
alan white
I'm not sure.  I'd have to check their software, but if it does what are you suggesting?  
It's just a possibility, but the app might be more forgiving if it is looking for a UNC path rather than a specific drive letter.  If the OS doesn't currect have, for example, an H: drive mapped, an application looking for H:\myfile.ini will never work.  Whereas an app looking for \\myserver\share\myfile.ini has a fighting chance of getting there.

A lot depends on how the app is written.
Commented:
Easy solution. Disable hibernation. Don't let it sleep. I never use it.
@tbarkdull:  Fair Point!

Author

Commented:
tbarkdull
lol well that ended this post.  but it is a laptop so i didn't want it to stay on constantly due to the heat factor of laptops.    

Commented:
Did you map the drives manually or through the group policy?
Is the PC in a workgroup or on the domain?

Author

Commented:
goraek
I mapped them manually and the laptop is in a workgroup

Author

Commented:
I really wanted a no user ended solution but the two answers combined will have to do.  thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial