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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stdout from wshshell.run

Status
Not open for further replies.

Dinobrago

Technical User
Dec 8, 2001
184
US
I am writing a vbs script that needs to execute an application. The application writes to Stdout and I need to capture the output.

Set objShell = CreateObject("WScript.Shell")
objShell.Run "app.exe input.dat output.dat", 1, True

With the "1" (rather than 0), a window pops up and I see the output spew by but the window closes immediately on completion. I need to either 1)pause the window before it exits or 2) capture the output to a text file.

Any ideas??

Dean
 
I'd try redirecting to see if that will do it for you.

Set objShell = CreateObject("WScript.Shell")
objShell.Run "app.exe input.dat output.dat > c:\myfile.txt", 1, True

good luck
 
Yes, I've tried that but the Run() method does not support redirection. At least, not with that syntax.

Dino
 
Try the following:

Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd /c app.exe input.dat output.dat > c:\myfile.txt", 1, True

I run this all the time. Should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top