Solved

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

Posted on 2004-10-07
2
1,955 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

687 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