作成 2009.12.29
更新 2009.12.29
更新 2009.12.29
コマンドを実行して実行結果をイベントログへ記録するサンプルコード
コマンドを実行して実行結果をイベントログへ記録します。
Option Explicit
Const evInfomation = 4
Dim WshShell, objExec
Dim strResult
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objExec = WshShell.Exec("sc query")
strResult = ""
Do While objExec.status = 0
Do While Not objExec.StdOut.AtEndOfStream
strResult = strResult & vbNewLine & objExec.StdOut.ReadLine
Loop
WScript.Sleep 100
Loop
WshShell.LogEvent evInfomation, strResult