[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

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

Industry Leaders: 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

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. …
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: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Suggested Courses

649 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