View Full Version : Mapping Network Drives (W2K)
AllenReyes
06-11-2002, 08:03 PM
Hello everyone. I'm just learning WSH (in VBasic)and would like to know how to conditionally map a network drive. For example:
If G:\ is not mapped Then
net.MapNetworkDrive "G:", "\\Server\Folder"
How do you declare the condition in the If statement? Would I have to declare a variable first and then use it in the statement? Thanks in advance for any help I can get.
Allen Reyes
Technical Assistant
KWB & Associates, Inc.
djcomplex
06-12-2002, 10:03 AM
i cant remember the exact context but , yes you need it to see if the connection exists if and the act accordingly, or you could add a disconnect script to your logouts and then just have a simple connect one on login
king_ging
06-22-2002, 08:36 PM
not too sure anymore but you can have a look at these options
1) If folderExists("G:\")
2) If driveExists(????) my memory is playing up so not sure if this one is possible
3) enumnetworkdrives will provide you with a list of all drives and then you can do a for next loop checking if the driveletter = "G:"
good luck
i will be able to put the exact context on here tomorrow when i am at work
good luck
RobertThunell
06-24-2002, 03:56 PM
Hello
Hope this one will help you!!
MapDrive "G:", "\\Server\Folder"
Function MapDrive(drv, nshare)
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set fs = CreateObject ("Scripting.FileSystemObject")
Dim fs, s
If (fs.DriveExists(drv)) Then s = WshNetwork.RemoveNetworkDrive(drv) End If
s = WshNetwork.MapNetworkDrive(drv, nshare)
'MapDrive = WshNetwork.MapNetworkDrive(drv, nshare)
MapDrive = s
End Function
Powered by vBulletin™ Version 4.1.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.