请教怎么获取DOS命令的返回值!【已解决】
本帖最后由 jwwlchen 于 2013-8-18 17:15 编辑如图,下面的命令会有一个“PASS”或“FAIL”的返回值,C:\Users\Administrator\Desktop\1\check>1.exe 123.txt
Pass
我现在使用这个命令将结果导入到一个文本中,然后再读取文本判断结果Dim $LogFile = "C:\Users\Administrator\Desktop\1\check\123.txt"
RunWait(@ComSpec & " /c " & "1.exe" & " " & $LogFile &"> 1.log", "", 0)但是我现在每天要判断的文件太多,4W左右,请问怎么用下面的命令不导出结果,直接获取结果??Dim $LogFile = "C:\Users\Administrator\Desktop\1\check\123.txt"
RunWait(@ComSpec & " /c " & "1.exe" & " " & $LogFile, "", 0) 论坛有个FAQ~~~ $msg_tasks_scsy = MsgBox(4 + 32, "提示", "是否删除所有任务", 0, $Tasks_Form)
If $msg_tasks_scsy = 6 Then
$foo_del = Run(@ComSpec & " /c " & 'SCHTASKS /Delete /TN * /F', @SystemDir, @SW_HIDE, 8)
ProcessWaitClose($foo_del)
MsgBox(64, "提示", StdoutRead($foo_del), 5, $Tasks_Form)
_tasks_list()
EndIf这是我其中一段代码,但是有的时候会显示乱码。 回复 3# xlcwxl
关键是最后那个参数8
[可选参数] 控制不同选项处理父进程与子进程交互.
0x1 ($STDIN_CHILD) = 提供一个句柄到子进程的 STDIN 流.
0x2 ($STDOUT_CHILD) = 提供一个句柄到子进程的 STDOUT 流.
0x4 ($STDERR_CHILD) = 提供一个句柄到子进程的 STDERR 流.
0x8 ($STDERR_MERGED) = Provides the same handle for STDOUT and STDERR. Implies both $STDOUT_CHILD and $STDERR_CHILD.
0x10 ($STDIO_INHERIT_PARENT) = Provide the child with the parent's STDIO streams. This flag can not be combined with any other STDIO flag. This flag is only useful when the parent is compiled as a Console application.
0x10000 ($RUN_CREATE_NEW_CONSOLE) = The child console process should be created with it's own window instead of using the parent's window. This flag is only useful when the parent is compiled as a Console application. http://www.autoitx.com/forum.php?mod=viewthread&tid=34569
风行者的UDF,非常强大 论坛有个FAQ~~~
haijie1223 发表于 2013-7-26 23:14 http://www.autoitx.com/images/common/back.gif
谢谢,以下方法已解决。#include <Constants.au3>
Dim $Log_File="123.txt"
Local $foo = Run(@ComSpec & " /c 1.exe" & " " & $Log_File, @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line,$lines
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
$lines &= $line
WEnd
MsgBox(0, "STDOUT read:", $lines) 高手啊啊啊 啊啊啊啊 呵呵。。学习了。。 这段时间在学习谢谢 请把标题前加上 【已解决】
谢谢配合!
页:
[1]