?
Solved

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

Posted on 2004-10-07
2
Medium Priority
?
1,988 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 375 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

801 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