我正在尝试检查驱动器是否映射到某个位置,如果没有,则将其映射到那里。如何查看驱动器的映射位置?我打算停止脚本,如果它被映射到错误的位置,并使用subst D: C:\folder
如果它没有被映射(这是我想要的),或者只是继续,如果它被映射到我想要的地方({{1}现在)
答案 0 :(得分:2)
取自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