Dim WShell : Set WShell = CreateObject("wscript.shell")
Dim oExec : Set oExec = WShell.Exec(commandLine)
Do While oExec.Status = 0
WScript.Sleep 100
Loop
If Not oExec.StdOut.AtEndOfStream Then
Dim stdOutput : stdOutput = "" & oExec.StdOut.ReadAll()
End If
Dim execResult : execResult = oExec.ExitCode
' Write error output and exit if result is not 0
If 0 <> execResult Then
Wscript.StdErr.Write stdOutput
Wscript.Quit execResult
End If
Dim oAPI : Set oAPI = CreateObject("MOM.ScriptAPI")
Call oAPI.LogScriptEvent("ActivatedApmAgent.RestartIIS.Task.vbs", 3202, 0, "Restart IIS task done.")