Solved Mapping networkdrive but getting folowing msg.

July 17, 2012 at 05:36:03
Specs: server 2008
Hi guys.

If i run the batch file I am getting this error when the networkdrives alredy are mapped. I want it to run a check and if the drives alredy is mapped then it shall do nothing.

What did i wrote wrong in my script?

I realy hope some nice persons can help me..


'Drive Map VBscript.vbs - Map Network Drive to Z:,Y:,V:
'Example of vBScript Mapping Three drives in one script.
Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3
Dim strProfile
Dim strUser
Dim strPassword
strDriveLetter1 = "Z:"
strDriveLetter2 = "Y:"
strDriveLetter3 = "V:"
strRemotePath1 = "\\***.***.***.***\********"
strRemotePath2 = "\\***.***.***.***\************"
strRemotePath3 = "\\***.***.***.***\***"
strUser = "******"
strPassword = "*******"
strProfile = "False"
set objNetwork = CreateObject("WScript.Network")
IF EXIST z:\*.* GOTO :nextif ELSE objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1, strProfile, strUser, strPassword
IF EXIST Y:\*.* GOTO :nextif2 ELSE objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2, strProfile, strUser, strPassword
IF EXIST V:\*.* GOTO :end ELSE objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3, strProfile, strUser, strPassword
'End of windows logon script.

See More: Mapping networkdrive but getting folowing msg.

Report •

July 17, 2012 at 18:53:08
✔ Best Answer
this is straight from the script help (except for name-change to match yours)
Set oDrives = objnetwork.EnumNetworkDrives
WScript.Echo "Network drive mappings:"
For i = 0 to oDrives.Count - 1 Step 2
WScript.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)

just adapt it to look for your letters, and make sure computers/resources are not already assigned (the odd-numberd elements are the resources, the even-numbered are the drive-letters). I don't think the batch "if exist" works in vbs, but i might be wrong.

Report •

July 18, 2012 at 05:08:25
I don't think the batch "if exist" works in vbs, but i might be wrong.
No, that's pretty much his problem. He's mixing Batch syntax and VBS syntax together in ways that confuse and frighten the script parser.

How To Ask Questions The Smart Way

Report •

Related Solutions

Ask Question