我有一个 vbscript 的“问题”。我检查 cd 是否加载了这段代码:
On Error Resume Next
Computer = "."
Set OutFile = CreateObject("WScript.Shell")
Const ForAppending = 2
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set WMIService = GetObject("winmgmts:\\" & Computer & "\root\cimv2")
Set Items = WMIService.ExecQuery("Select * from Win32_CDROMDrive WHERE DRIVE = 'F:'",,48)
For Each SubItems in Items
WScript.Echo "DRIVE: "&SubItems.MediaLoaded
Next
它返回“驱动器:假”
但是,如果我更改打印输出的行:
WScript.Echo SubItems.MediaLoaded
返回 -1
有人知道我怎么能得到 "DRIVE:-1" 吗?
我用 WScript.Echo "DRIVE: "&cint(SubItems.MediaLoaded) 解决了感谢 madzone