Iska
04-04-2014, 20:00
Напрасно.
Option Explicit
Dim objSWbemObjectEx
Dim objFSO
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
With GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
For Each objSWbemObjectEx In .ExecQuery("SELECT * FROM Win32_LogicalDisk")
If objFSO.FileExists(objSWbemObjectEx.Name & "\1") Then
Exit For
End If
Next
For Each objSWbemObjectEx In objSWbemObjectEx.Associators_(,"Win32_DiskPartition")
Exit For
Next
For Each objSWbemObjectEx In objSWbemObjectEx.Associators_(,"Win32_DiskDrive")
Exit For
Next
WScript.Echo objSWbemObjectEx.DeviceID
End With
Set objFSO = Nothing
WScript.Quit 0
Если файл не будет найден — будет ошибка.
Option Explicit
Dim objSWbemObjectEx
Dim objFSO
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
With GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
For Each objSWbemObjectEx In .ExecQuery("SELECT * FROM Win32_LogicalDisk")
If objFSO.FileExists(objSWbemObjectEx.Name & "\1") Then
Exit For
End If
Next
For Each objSWbemObjectEx In objSWbemObjectEx.Associators_(,"Win32_DiskPartition")
Exit For
Next
For Each objSWbemObjectEx In objSWbemObjectEx.Associators_(,"Win32_DiskDrive")
Exit For
Next
WScript.Echo objSWbemObjectEx.DeviceID
End With
Set objFSO = Nothing
WScript.Quit 0
Если файл не будет найден — будет ошибка.