Start mapping drive after ping sucessfully?

Status
Not open for further replies.

MaMister

Solid State Member
Messages
7
Hi all, I was wondering if there is a way to start mapping a network drive only after successfully ping the server? Is it possible to run this when windows is loaded?

Thanks.
 
is there any reason you can't use UNC? e.g. \\servername\share


you can save this code to a .vbs file and add to startup folder. it will try to map the drive repeatedly and not show any errors. it ends when the drive is mapped.

Code:
'set drive letter
drive = "Z:"

'set share
share = "\\Server\PublicFiles"

'set delay
delay = 3000 ' in milliseconds

'start network object
Set WshNetwork = WScript.CreateObject("WScript.Network")

'start file system object
Set filesys = CreateObject("Scripting.FileSystemObject")

'do not show errors
on error resume next

'repeat until the drive in found
do until filesys.driveexists(drive)

'create drive mapping
WshNetwork.MapNetworkDrive drive, share

'short delay
wscript.sleep(delay)

'send back to do statement
loop

'turn errors back on
on error goto 0

'cleanup
Set WshNetwork = nothing

Set filesys = nothing
 
Thanks, I will try this few days.

Btw, where to put in the user name and password and domain if there is one?
 
Status
Not open for further replies.
Back
Top Bottom