本帖最后由 zghwelcome 于 2023-8-31 20:45 编辑
_GetError_Demo1()
_GetError_Demo2()
_GetError_Demo3()
Func _GetError_Demo1();// excute command
Local $iPID = Run(@ComSpec & ' /k @echo off & (dir /b/ad d:\abcdefg && echo,error=0)||echo,error=1 ', @SystemDir, @SW_HIDE, 0x8)
ProcessWaitClose($iPID)
Local $sRet = BinaryToString(StdoutRead($iPID, 1, 1), 1)
MsgBox(0, 0, $sRet)
EndFunc ;==>_GetError_Demo1
Func _GetError_Demo2();//Run Bat
Local $iPID = Run(@ComSpec & ' /k @echo off&call "' & @ScriptDir & '\Run.bat" ', @SystemDir, @SW_HIDE, 0x8)
ProcessWaitClose($iPID)
Local $sRet = BinaryToString(StdoutRead($iPID, 1, 1), 1)
MsgBox(0, 0, $sRet)
EndFunc ;==>_GetError_Demo2
Func _GetError_Demo3();//fc.exe
Local $iPID = Run(@ComSpec & ' /k @echo off& fc.exe "' & @ScriptDir & '\1.txt" "' & @ScriptDir & '\2.txt" 0<&1', @SystemDir, @SW_HIDE, 0x8)
ProcessWaitClose($iPID)
Local $sRet = BinaryToString(StdoutRead($iPID, 1, 1), 1)
MsgBox(0, 0, $sRet)
EndFunc ;==>_GetError_Demo3
Run.bat@echo off
dir /b/ad d:\
echo,error=%errorlevel%
|