Reputation: 73
I want to check whether the network drive had map before I map the network drive. I use this code to map the drive.
Dim network = New IWshNetwork_Class()
network.MapNetworkDrive("Z:", ServerDc, Type.Missing, username, pwd)
Upvotes: 1
Views: 2287
Reputation: 3991
IWshNetwork_Class
appears to be a class in the Windows Script Host Object Model COM library.
Dim Network As IWshRuntimeLibrary.IWshNetwork_Class
Dim Drives As IWshRuntimeLibrary.IWshCollection_Class
Drives = Network.EnumNetworkDrives
For DriveCounter As Long = 0 To Drives.Count – 1 Step 2
MsgBox(Drives.Item(DriveCounter) & " is mapped to " & Drives.Item(DriveCounter + 1))
Next
Have a look at this PDF for more information...
Upvotes: 2