使用 UFT 从控制台读取的元素数量错误
Wrong Number of Elements for reading from console with UFT
我有以下关于 UFT 的简单问题。
我的脚本是:
Dim testShell
Set testShell = CreateObject ("wscript.shell")
testShell.exec "cmd /K CD C:\ & Dir"
msgbox(testShell.Exec.StdOut)
这给了我以下错误:
Wrong number of Arguments : 'testShell.exec' Line (4): "msgbox(testShell.Exec.StdOut)".
到目前为止,我已经看过几个 VbScript,它们似乎都可以正常工作。为什么我的脚本会失败?我非常确定这是非常愚蠢和简单的事情,但我看不到我的错误。我只想将 shell 的输出放入一个变量中,以便我可以使用它。
您需要 .Exec 返回的对象来获取 .StdOut 及其内容,/K
应该是 /C
:
>> Set testShell = CreateObject ("wscript.shell")
>> Set oExec = testShell.exec("%comspec% /C CD C:\ & Dir")
>> WScript.Echo oExec.StdOut.ReadAll()
>>
Volume in drive C has no label.
...
25.05.2011 19:32 <DIR> apache-ant-1.8.2
...
我有以下关于 UFT 的简单问题。
我的脚本是:
Dim testShell
Set testShell = CreateObject ("wscript.shell")
testShell.exec "cmd /K CD C:\ & Dir"
msgbox(testShell.Exec.StdOut)
这给了我以下错误:
Wrong number of Arguments : 'testShell.exec' Line (4): "msgbox(testShell.Exec.StdOut)".
到目前为止,我已经看过几个 VbScript,它们似乎都可以正常工作。为什么我的脚本会失败?我非常确定这是非常愚蠢和简单的事情,但我看不到我的错误。我只想将 shell 的输出放入一个变量中,以便我可以使用它。
您需要 .Exec 返回的对象来获取 .StdOut 及其内容,/K
应该是 /C
:
>> Set testShell = CreateObject ("wscript.shell")
>> Set oExec = testShell.exec("%comspec% /C CD C:\ & Dir")
>> WScript.Echo oExec.StdOut.ReadAll()
>>
Volume in drive C has no label.
...
25.05.2011 19:32 <DIR> apache-ant-1.8.2
...