954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

run a cmd code in mfc app

Hello! I'm a beginner in the worl of C++. I'm building a program that acts as a launcher for a game. In it I have Start and Exit button. What I want the Start button to do is start an .exe with extra conditions: IP and Port.

if (nResponse == IDOK)
	{
		// Code when hit Start
	}


Code what I want to enter is:

dklegend.exe NEWSTART Futec(***********:9909)


How should I have my if condition written to make this happen?

The app is an MFC!

DKDeath
Newbie Poster
7 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

:S been 11 hrs and no one replied.. I guess I'll go by the title of this thread

"run a cmd code in mfc app"

cmd commands would be as useful as using system();
so for the cmd command: taskkill /F /IM notepad.exe
you would write in c++ system("task kill /F /IM notepad.exe");

As for the game your trying to start, I would say right cick the exe and press properties.. in the target field I guess u can enter +port 27015 or whatever.. At least thats how it works for most games.. in c++ im not sure how you would go about that.. other than the system(); call

triumphost
Posting Whiz
390 posts since Oct 2009
Reputation Points: 57
Solved Threads: 36
 

There are at least three ways to launch a process -- system(), ShellExecute() and CreteProcess(). Which one you want to use depends on how much control you want over the newly created process. google for those functions and you will see how to use them. CreateProcess() is the most complicated, but also gives you the most control.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thank you for your help on this!

DKDeath
Newbie Poster
7 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: