【问题标题】:Writing into Application and Services Log with VBscript使用 VBscript 写入应用程序和服务日志
【发布时间】:2017-06-12 12:50:57
【问题描述】:

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

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

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

能否告诉我是否可以使用 VBscript 写入应用程序和服务日志?

【问题讨论】:

    标签: vbscript event-log custom-eventlog


    【解决方案1】:

    只需使用 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
    

    【讨论】:

    • 谢谢,请原谅我迟到的回复。好的,这是唯一的解决方案...
    猜你喜欢
    • 1970-01-01
    • 2021-08-07
    • 2018-04-09
    • 1970-01-01
    • 1970-01-01
    • 2021-09-13
    • 2018-08-15
    • 2014-11-01
    • 2012-04-25
    相关资源
    最近更新 更多