我在 WMI 中使用此页面上的最后一个示例打印出一些 Windows 系统日志信息:http: //msdn.microsoft.com/en-us/library/aa394593 (VS.85).aspx
我也想打印出二进制数据,但我不确定如何在 WScript 中执行此操作。这是我修改后的代码:
' test.vbs
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent " _
& "Where Logfile = 'System' and SourceName = 'MySource'")
For Each objEvent in colLoggedEvents
Wscript.Echo "Category: " & objEvent.Category & VBNewLine _
& "Event Code: " & objEvent.EventCode & VBNewLine _
& "Message: " & objEvent.Message & VBNewLine _
& "Time Written: " & objEvent.TimeWritten & VBNewLine _
& "Event Type: " & objEvent.Type & VBNewLine _
& "Binary Data: " & objEvent.Data
Next
运行 test.vbs 时,我从 Windows Script Host 收到此错误消息:
错误:类型不匹配,代码:800A000D,来源:Microsoft VBScript 运行时错误
知道如何将数据打印为十六进制字符串吗?