Link to home
Start Free TrialLog in
Avatar of tourist08
tourist08Flag for United States of America

asked on

Reconnect mapped drive script

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.  
Avatar of Alan_White
Alan_White
Flag of United Kingdom of Great Britain and Northern Ireland image

NET USE H: \\server\share /persistent:yes
Avatar of tourist08

ASKER

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?  
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

ASKER CERTIFIED SOLUTION
Avatar of Tony Barkdull
Tony Barkdull
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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"?
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?
Modify it for the proper drive letter, server name and shared path then save it as a .vbs file and just double click it.
Any way I can get something that will run when the laptop comes out of standby, instead of having the user click a file?
johnb6767
Yes there is an app the relies on the mapped drives.  
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.....
johnb6767
What do you mean by a unc path via registry?  
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?
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?
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@tbarkdull:  Fair Point!
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.    
Did you map the drives manually or through the group policy?
Is the PC in a workgroup or on the domain?
goraek
I mapped them manually and the laptop is in a workgroup
I really wanted a no user ended solution but the two answers combined will have to do.  thanks