i have vbs file with a few command line utilities that need to be run.
but in certain cases, these utils may prompt for input from the user to continue. i want to be able to trap those conditions, supply a defualt answer of “yes” and then continue.
here’s what i have so far:
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"
when i do this, nothing happens. i see the debug statement i have inserted… but the script just seems to hang.
any help would be appreciated.
Use pipes:
echo y | your_command. This will put ‘y’ into stdin of the your process.If next command doesn’t use stdin as an input (its implemetation uses keyboard related API) then there is no simple way to fix this.