我有以下代码来捕获和处理Run命令输出.如何修改它以使"运行"命令窗口显示输出并同时记录输出?@SW_HIDE用@SW_SHOW(或等效的)替换只显示一个空白的命令窗口.
类似于linux tee命令的东西,它在打印STDOUT时记录到文件.
$CurrentPID = Run(@ComSpec & ' /c ' & $CurrentLogCmd, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
If Not ProcessWaitClose($CurrentPID,60) Then
WriteLog("[Warning] Timed-out.Finding date in current hour raw log -" & $CurrentLogFileName)
$F_LogWarningExist = 1
Return $C_SUCCESS ; Take chances and proceed with parsing raw logs
EndIf
$CurrentOutput = StdoutRead($CurrentPID)
Run Code Online (Sandbox Code Playgroud)
ConsoleWrite(_getDOSOutput('ipconfig /all') & @CRLF)
Func _getDOSOutput($command)
Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, '', @SW_HIDE, 2 + 4)
While 1
$text &= StdoutRead($Pid, False, False)
If @error Then ExitLoop
Sleep(10)
WEnd
Return StringStripWS($text, 7)
EndFunc ;==>_getDOSOutput
Run Code Online (Sandbox Code Playgroud)
也许这对你有帮助。
| 归档时间: |
|
| 查看次数: |
17933 次 |
| 最近记录: |