Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

obShell Exec vs. Run

Status
Not open for further replies.

ggolub

Programmer
Jan 5, 2005
13
US
hello Forum,

I need to execute windows .cmd file which produces output which I need to catch. It expects for input in 2 places: 'yes',enter; enter.

Can you recommend me how to do it.
From what I understand, Exec can collect output but does not let to send command strokes with objShell.SendKeys

obshell.Run let you use sendkeys but I am having troubles to collect output.
When I tried to run t1.cmd > t1.out ,
t1.out collects output till first prompt. Then all output goes on counsel.
 
Use the Exec method and play with the StdIn and StdOut properties.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you Gentleman for your help.
PHV, I followed your path and made it work.

I want to ask you another question:
Is there anyway to prevent output from command line execution from within objShell.Exec going to my command line window?
It producess a lot of output which I want to display for debugging purporses but generally want to hide.

Meanwhile I came accross interesting phenomena:
StdOut and StdIn streams switched their methods.

Here is what I mean:
To catch input line, I used:
objExec.StdOut.Readlin

To respond on command line prompt from vbs I used:
objExec.StdIn.WriteLine.

I must be confused by something but WriteLine method belonds to StdOut stream.
But it works.
 
objExec.StdOut.Readlin
Your script reads the standard output written by the command.

objExec.StdIn.WriteLine
Your script writes to the standard input read by the command.



Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV - thank you so much - it make sence.

Do you have any recommendations on how to hide output produced by the command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top