aku1 发表于 2006-6-16 17:01:00 |
主要感觉还缺少错误处理的代码,以后加强,(其中利用了动态数组:))
Dim WshNetwork Dim strComputer Dim strDrive Dim objWMIService Dim colDisks Dim objDictionary Dim arrTestArray() intSize = 0
Set WshNetwork = WScript.CreateObject("WScript.Network") Set objDictionary = CreateObject("Scripting.Dictionary")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")
For Each objDisk in colDisks
objDictionary.Add objDisk.DeviceID, objDisk.DeviceID
Next For i = 67 to 90
strDrive = Chr(i) & ":"
If objDictionary.Exists(strDrive) Then
Else ReDim Preserve arrTestArray(intSize) arrTestArray(intSize) = strDrive intSize = intSize + 1 End If Next Wscript.Echo arrTestArray(0) & " is the next available drive letter." WshNetwork.MapNetworkDrive arrTestArray(0), "\\macs-szmail1\Data\Pmc"
|