2017-06-12 39 views
0

在我的PowerShell脚本中,我使用此cmdlet将应用程序和服务日志写入自定义日志中。用VBscript写入应用程序和服务日志

write-eventlog -logname "MyRemoteSuite" -source "MRP" -eventid 100 -Message $Msg 

它运作良好。现在我需要对VBscript做同样的事情......但EventCreate仅限于Windows事件日志。我也发现this stackoverflow post,我不知道这是不是很好的解决方案。

你能告诉我如果写入VBscript的应用程序和服务日志是可能的吗?

回答

0

只需使用VBScript的Run方法执行PowerShell命令即可。

Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "CMD /K POWERSHELL -Command write-eventlog -logname ""MyRemoteSuite"" -source ""MRP"" -eventid 100 -Message Msg", 1, False 
+1

谢谢,请原谅我迟到的回应。好吧,这是唯一的解决方案... – mrplume

相关问题