vbs调用exec执行dos命令之诡异细节

情况一 没有“cmd /c ”开头去执行dos命令(dos命令带有管道操作符和其他命令),单独一个dos命令有没有cmd开头貌似都没啥异常

Set oExec=WshShell.exec(" netstat -ano|findstr 843")

Set oStdOut = oExec.StdOut
strLine = oStdOut.ReadLine

此时strline 为空。也就是oStOut里面没有接受到东西。

情况二 加上“cmd /c ”

Set oExec=WshShell.exec("cmd /c netstat -ano|findstr 843")

Set oStdOut = oExec.StdOut
strLine = oStdOut.ReadLine

此时strLine 就有内容了。

posted on 2015-06-03 13:49  念珠  阅读(734)  评论(0编辑  收藏  举报

导航