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

[AU3基础] 无法读取dos回显

  [复制链接]
发表于 2013-4-9 23:06:21 | 显示全部楼层 |阅读模式
#include <Constants.au3>
$run = Run(@ComSpec & ' /c schtasks /end /tn "test"', @SystemDir, @SW_HIDE,$STDOUT_CHILD)
ProcessWaitClose($run)
$text=StdoutRead($run)
MsgBox(0, "STDOUT read:", $text)
只能读取部分命令,如sctasks就能回显,但是命令打全了就不显示了?还有其他办法处理吗?
发表于 2013-4-10 07:53:19 | 显示全部楼层
应该是因为系统中不存在test任务的原因,找个存在的任务,然后运行代码试试。
发表于 2013-4-10 07:58:29 | 显示全部楼层
用 schtasks /query 命令试一下,end是结束正在运行的任务~可能test任务没有在运行,所以失败,失败的命令好像获取不到~例如 dir w: 一般很少有电脑到w分区,这个命令应该是无效的,你试下会获取到不,然后再试下c:
 楼主| 发表于 2013-4-10 16:45:35 | 显示全部楼层
回复 3# haijie1223

我的目的就是,无论是否存在都应该有提示的,西面是在命令提示符下获取到的:

C:\Users\Administrator>schtasks /end /tn "test"
错误: 系统找不到指定的文件。

是au3程序的缺陷还是方法不对?
发表于 2013-4-11 19:36:57 | 显示全部楼层
$STDOUT_CHILD) 改为15(包含错误输出流)
 楼主| 发表于 2013-4-11 20:03:26 | 显示全部楼层
回复 5# Qokelate

厉害,真的解决了,这参数在哪里看的?
发表于 2013-4-11 20:27:51 | 显示全部楼层
回复 6# xlcwxl
其实run 可选标志里有  $STDERR_MERGED 这个就是
 楼主| 发表于 2013-4-11 21:16:38 | 显示全部楼层
回复 7# lchl0588


谢谢!
发表于 2013-4-11 21:40:06 | 显示全部楼层
Run ( "程序" [, "工作目录" [, 显示标志[, 可选标志]]] )

[可选参数] 控制不同选项处理父进程与子进程交互.
  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.

1+2+4+8    =15
发表于 2013-4-12 06:57:49 | 显示全部楼层
回复 9# Qokelate


    还真没注意到,学习了~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-11 18:09 , Processed in 0.127082 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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