2017-06-12 59 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

相關問題