使用vbscript从服务器2008上的事件日志复制打印记录
我需要使用 vbscript 复制 Windows Server 2008 r2 x64 上打印作业的日志文件。 我现在的代码适用于服务器 2003。当我在 2008 服务器上运行它时,我没有收到任何错误,但文件中没有任何内容。这是代码
Set ObjFso = CreateObject("Scripting.FileSystemObject")
StrFileName = "C:\printer report test\eventlog_norprtfl1.tsv"
strComputer = "servername"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where LogFile='Microsoft-Windows-PrintService/Operational' and EventCode='307'")
Set ObjFile = ObjFso.CreateTextFile(StrFileName)
For Each objItem in colLoggedEvents
objFile.WriteLine("x64^"&objItem.User&"^"&objItem.TimeWritten&"^"&objItem.Message)
Next
I need to copy the log files that are print jobs on a windows server 2008 r2 x64 with vbscript.
The code I have now works with server 2003.When I run it on the 2008 server I don't get any errors but nothing is in the file. Here is the code
Set ObjFso = CreateObject("Scripting.FileSystemObject")
StrFileName = "C:\printer report test\eventlog_norprtfl1.tsv"
strComputer = "servername"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent Where LogFile='Microsoft-Windows-PrintService/Operational' and EventCode='307'")
Set ObjFile = ObjFso.CreateTextFile(StrFileName)
For Each objItem in colLoggedEvents
objFile.WriteLine("x64^"&objItem.User&"^"&objItem.TimeWritten&"^"&objItem.Message)
Next
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论