Jump to content
  • Advertisement
Sign in to follow this  
VISQI

Run from command?

This topic is 2541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey people
So i want to run a console application and output some data to a file and then run a windows subsystem application right after the console application finishes. How do i do that??
I basically want to run Main() and output some data to a file and then - without user input - run the WinMain() application and use the data outputted from the Main().

Share this post


Link to post
Share on other sites
Advertisement

Hey people
So i want to run a console application and output some data to a file and then run a windows subsystem application right after the console application finishes. How do i do that??
I basically want to run Main() and output some data to a file and then - without user input - run the WinMain() application and use the data outputted from the Main().


why output to a file ?

you could just do:

consoleapp.exe | windowedapp.exe

Whatever consoleapp.exe writes to stdout windowedapp will read from stdin. (Assuming pipes work with windowed applications in windows)

Share this post


Link to post
Share on other sites
Depending on your language and IDE it could be as simple as adding it to the tear down. I know in Visual Studio you can set pre-compile/pre-runtime and if I remember correctly post runtime commands.

Share this post


Link to post
Share on other sites
You can use the system() function to execute a command in the same way you'd use the command prompt. Or you can use the CreateProcess function if you need a higher degree of control. Either way you can pass parameters which is the simplest way of getting data from the first program to the second.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

Share this post


Link to post
Share on other sites
sorry for the late reply. I had a connection problem.
i am using C++. forgot to say it :)
and windows 7
i am pretty much a newbie when it comes to windows programming. i just know how to make a blank screen :)
So basically compile the main() console application by invoking ShellExecute() in the WinMain() windows app, right??
but what operation should i use?? there is no "execute" operation
Is there another way??

and what is this??



why output to a file ?

you could just do:

consoleapp.exe | windowedapp.exe

Whatever consoleapp.exe writes to stdout windowedapp will read from stdin. (Assuming pipes work with windowed applications in windows)

Share this post


Link to post
Share on other sites
In general, if you don't know what verb to use for a file, you can just pass NULL to ShellExecute()'s lpOperation parameter. You can also use CreateProcess() to run an executable or the Ex forms of the functions.

What SimonForsman was referring to was a command line pipe. In this case it involves the stdout from the first program being received as input as stdin in the second program.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!