找回密码
 加入
搜索
查看: 8063|回复: 9

[AU3基础] 请教怎么获取DOS命令的返回值!【已解决】

  [复制链接]
发表于 2013-7-26 22:57:26 | 显示全部楼层 |阅读模式
本帖最后由 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)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-7-26 23:14:20 | 显示全部楼层
论坛有个FAQ~~~
发表于 2013-7-27 08:50:11 | 显示全部楼层
$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
这是我其中一段代码,但是有的时候会显示乱码。
发表于 2013-7-27 08:53:09 | 显示全部楼层
回复 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.
发表于 2013-7-27 13:32:57 | 显示全部楼层
 楼主| 发表于 2013-7-28 00:20:22 | 显示全部楼层
论坛有个FAQ~~~
haijie1223 发表于 2013-7-26 23:14



谢谢,以下方法已解决。
#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)
发表于 2013-7-29 02:30:04 | 显示全部楼层
高手啊啊啊 啊啊  啊啊
发表于 2013-8-1 09:45:40 | 显示全部楼层
呵呵。。学习了。。
发表于 2013-8-1 15:08:43 | 显示全部楼层
这段时间在学习谢谢
发表于 2013-8-2 11:05:31 | 显示全部楼层
请把标题前加上 【已解决】
谢谢配合!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 23:23 , Processed in 0.111340 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表