File 如何通过vbs执行命令

File 如何通过vbs执行命令,file,cmd,prompt,File,Cmd,Prompt,我有vbs文件和一些需要运行的命令行实用程序。 但在某些情况下,这些UTIL可能会提示用户继续输入。我希望能够抓住这些条件,给出一个“是”的否定答案,然后继续 以下是我目前掌握的情况: Dim oExec set oExec = objShell.Exec("mycmd pw ....") do while not oExec.StdOut.AtEndofStream wscript.echo "status of script: " & oExec.Status in

我有vbs文件和一些需要运行的命令行实用程序。 但在某些情况下,这些UTIL可能会提示用户继续输入。我希望能够抓住这些条件,给出一个“是”的否定答案,然后继续

以下是我目前掌握的情况:

Dim oExec
set oExec = objShell.Exec("mycmd pw ....")

do while not oExec.StdOut.AtEndofStream
    wscript.echo "status of script: " & oExec.Status
    input = input & oExec.StdOut.ReadLine()
    if instr(input, "create key? (y/n)") <> 0 Then exit do
loop
oExec.Stdin.Write "y"
Dim oExec
设置oExec=objShell.Exec(“mycmd pw….”)
不要执行oExec.StdOut.AtEndofStream
wscript.echo“脚本状态:&oExec.status”
input=input&oExec.StdOut.ReadLine()
如果instr(输入,“创建键?(y/n)”)0,则退出do
环
oExec.Stdin.写“y”
当我这么做的时候,什么也没发生。我看到我插入的调试语句。。。但剧本似乎挂了


如有任何帮助,我们将不胜感激。

您是否已尝试将输入内容放入文件并使用


cmdfile.cmd
使用管道:
echo y |您的_命令
。这会将“y”放入进程的stdin中

如果next命令不使用stdin作为输入(它的实现使用键盘相关的API),那么就没有简单的方法来解决这个问题