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

How to execute processes

I am trying to create a simple program that starts up steam from my computer. I have a shortcut on my desktop of steam and when you double click it, it runs the process "steam.exe"


When my program executes the line of code "system("start steam.exe")" I get an error saying that windows cannot find steam.exe.

How do I fix this?

Shadoninja
Light Poster
37 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Provide the full path to the executable? But really, if your program merely opens a canned program, why not go with just a link to that program to begin with?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This is just practicing the basics to make sure my memory hasn't faded :)

But when entering the full path, do I put it in the same string as "start" or is this method different?

Shadoninja
Light Poster
37 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

This would be my first guess:

system("start path/to/steam.exe");
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This would be my first guess:

system("start path/to/steam.exe");


That is what I first tried but it got an error

I put it

system("start C:\Program_Files\Steam\steam.exe");

but I get an error saying it can't find "C:Program_FilesSteamsteam.exe"

it reads it without the backslashes. Is that because of dev-c++?


EDIT: I changed the backslashes to forward slashes but it still says it can't find "C:/Program Files/Steam/steam.exe"

Shadoninja
Light Poster
37 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Try

system("start \"C:/Program Files/Steam/steam.exe\"");
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

hmm that took me to a separate dos window that just repeated the path file of my .cpp back to me

Shadoninja
Light Poster
37 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Yup. Let's 86 the 'start'.

system("\"C:/Program Files/Steam/steam.exe\"");
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

awesome thank you for the help!

Oh yeah, now is there a way to check if steam is already running before it tries to execute it?

Shadoninja
Light Poster
37 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Maybe something like this .

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You