Solved

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

Posted on 2004-10-07
2
1,858 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

759 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

22 Experts available now in Live!

Get 1:1 Help Now