Solved

Using ShellExecute() to open file and pipe output to file

Posted on 2004-10-07
2
1,870 Views
Last Modified: 2013-11-17
If how can I pipe the output of a dos .exe file to another file.

If I start the program with C:\runme.exe paramerteer >> output.txt the output will not be shown on the screen but written to output.txt

If i use:
ShellExecute(NULL, "open", "c:\\runme.exe", "parameter >> output.txt", NULL, SW_SHOWNORMAL);
runme.exe start up but dont write output to output.txt.
0
Comment
Question by:Bjo020
2 Comments
 
LVL 9

Accepted Solution

by:
Cayce earned 125 total points
ID: 12255049
Use PIPES :)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/pipe_functions.asp

It's not hard to accomplish. But the learning curve is steep.

You'll need to use CreateProcess (which ShellExecute internally calls). http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp

Just specify your own stdin, stdout and stderr (which should be pipes).

Now work with the pipes as standard files. (Remember to input anyting the app needs through stdin).

Check this example:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp

Good luck!

PS. I just had to do this a few weeks ago. It was really fun.
0
 

Author Comment

by:Bjo020
ID: 12265414
Just what i needed.
The examples worked on first try and now only needs to be customized.

thx.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now