Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a c++ application that spawns a shell program called, "rtireplaysh.exe".

I execute the rtishellsh.exe using shellexecute and can use CreateProcess.

The commands that rtishellsh.exe excepts are stop, start, pause and resume.

QUESTIONS:
1. After the shell application is up and running how can I pass these commands to the prompt?

2. Is there a way to execute rtishellsh.exe and pass "stop", "start", "pause" and "resume" ?

Any ideas?
Posted
Updated 1-Nov-11 4:28am
v2

Use CreateProcess, create a pipe and pass it as a hStdInput in the STARTUPINFO structure and then you can write the "stop" "start" commands to the pipe, refer this article for how to redirect the stdin and stdout

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499%28v=vs.85%29.aspx[^]
 
Share this answer
 
Comments
Chuck O'Toole 2-Nov-11 2:38am    
Nice
mikwilmot 3-Nov-11 10:58am    
I will try and implement this today. Thanks so much for your help. I will comment on this later today to see if it works. You all are great!
The documentation for CreateProcess http://msdn.microsoft.com/en-us/library/ms682425%28v=VS.85%29.aspx[^] shows how to set the lpCommandLine to pass arguments to the application and discusses how the application can get those arguments. That should do the trick.
 
Share this answer
 
Comments
mikwilmot 1-Nov-11 11:01am    
Hi Chuck, Thanks for the response.
My lpCommandLine is:
"rtireplaysh.exe -cfgName mission -cfgFile mission1.xml"

This starts rtireplaysh.exe, loads the mission and reads the mission1.xml file. Then this prompt pops up.

rtireplay ->

How do I get stop, start, resume and pause into the prompt?
Chuck O'Toole 1-Nov-11 11:31am    
You don't. There's no way for you to stuff things into the input stream directly. Instead, you should teach your code new command line args that provide those answers and have the program avoid the prompt / read code and use the command line provided response. In other words, create an "extended command line mode, no user input allowed" mode for your program.

Of course, you could experiment with Batch/.CMD files and have the main program create an entire script with inputs redirected from data files with prompts etc. Not something I do unless forced or paid to do.
rtireplaysh.exe is a 3rd party application and I cannot change how it accepts commands. rti.com/support recommended using fgets and fputs.

Funny part was when I asked them about this they said that they would create an enhancement so that I could build a new xml file that could be read by rtireplaysh.exe with the stop, start.... commands embedded.

Thanks for taking a look at this.
 
Share this answer
 
Comments
Chuck O'Toole 1-Nov-11 11:41am    
Then you need to experiment with Batch / CMD files to run the app and provide inputs. I can't provide examples as I don't do that kind of thing.
shellexecute

UAC problem

win7 have purview ~~~~~~~~~

WTL MFC have variable

win32 GetCommandline()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900