Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drive mapping

Status
Not open for further replies.

Lordmathos

IS-IT--Management
Oct 21, 2005
243
GB
Hi All I won't lie to you. I know nothing about VBscript.

I am working on a basic logon script to map network drives (as follows)

Dim wshNetwork
Set wshNetwork = CreateObject("Wscript.Network")
wshNetwork.MapNetworkDrive "I:", "\\server1\backups"
WSCript.Quit

The problem I am having is the script will error if it tries to create the network drive if the drive already exists.

How do I add an "IF" statement so it will skip creating the drive if it is already present?
 
Easiest way is to On Error Resume Next.

Code:
Dim wshNetwork
On Error Resume Next
Set wshNetwork = CreateObject("Wscript.Network")
wshNetwork.MapNetworkDrive "I:", "\\server1\backups"
Set wshNetwork = Nothing
WScript.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top