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

ShellExecuteEx issue

Status
Not open for further replies.

SLider3

Programmer
Jun 17, 2003
56
0
0
PT
Hi

I'm using ShellExecuteEx to run a dos program from my bcb aplication. In lpFile i put the path to the program, and in lpParameters the line with parameters.
well, the dos program sends some messages to the monitor and i want to save them to a file.
If I run the program in command pronpt it's easy to do that:
prog.exe -i something - o something_else 2> output.txt
( 2> because i know it sends the messages to stderr)

I tried do had the " 2> output.txt" to the lpParameters string but it's not working. :\
So, how can i save those messages to a file?
 
Nobody knows what i have to do?
I wasn't clear enought?
 
Come on ...it has to be a way to redirect the stderr to a text file using ShellExecuteEx.

Please ... i need help on this one.
 
I must admit, I've never tried it. Have you thought about putting the whole "prog.exe -i something - o something_else 2> output.txt" in the executable line?


James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
Well ...i'm executing the external program using ShellExecuteEx.
I put:
Code:
SHELLEXECUTEINFO sei;
memset(&sei, 0, sizeof(sei));
sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_NOCLOSEPROCESS + SEE_MASK_FLAG_NO_UI;
sei.hwnd = NULL;
sei.lpVerb = "Open";
sei.lpFile = "prog.exe";
sei.lpParameters = "-i something - o something_else"
and the program is executed.


Then i changed the lpParameters to:
Code:
sei.lpParameters = "-i something - o something_else 2> output.txt"
But it doesn't run.
 
I'm shooting in the dark but have you tried:
Code:
sei.lpFile = "prog.exe -i something - o something_else 2> output.txt"
sei.lpParameters = ""

James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
It looks like it should work with the lpParameters. This is probably a stupid question but I can't see why it won't work, but have you tried this at the command prompt to see it it will work there?



James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
yeah, at the command prompt it works fine.
 
So, nobody knows how to help me? Noone never needed to do such thing?
 
I haven't tried it. Have you tried CreateProcess? More complex but it might work.


James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top