I have a "problem" with a vbscript. I check if a cd is loaded with this piece of code:
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
It returns "DRIVE: False"
But if I change the line that prints the output for:
WScript.Echo SubItems.MediaLoaded
Returns -1
Someone knows how I could get "DRIVE:-1" ?
I solved with WScript.Echo "DRIVE: "&cint(SubItems.MediaLoaded) thanks to madzone