VBScript how to check what a drive is mapped to
I'm trying to check if a drive is mapped to a certain spot, and map it there if its not. How can I check where a drive is mapped? I'm planning on stopping the script if it's mapped to the wrong spot, and using subst D: C:\folder
if it's not mapped (which is what 开发者_如何转开发I wanted) or just continuing on if it's mapped to where I want (C:\folder
for now)
Taken from http://msdn.microsoft.com/en-us/library/t9zt39at(v=vs.85).aspx
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
Set oPrinters = WshNetwork.EnumPrinterConnections
WScript.Echo "Network drive mappings:"
For i = 0 to oDrives.Count - 1 Step 2
WScript.Echo "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
Next
WScript.Echo
WScript.Echo "Network printer mappings:"
For i = 0 to oPrinters.Count - 1 Step 2
WScript.Echo "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1)
Next
精彩评论