Irakli Lekishvili
Irakli Lekishvili

Reputation: 34158

c++ run .exe file with parameters

Im trying to run exe file with c++ with no luck

I tried this:

system("C:\\Program Files (x86)\\Counter-Strike Condition Zero 1.2 build 2771\\hl.exe");

How i can run hl.exe with parameters?

Thanks

Update:

'C:\Program' is not recognized as an internal or external command, operable program or batch file im getting this error.

I tried system("C:\\hl.exe"); and it works good. I think problem is in whitespaces

Upvotes: 2

Views: 17350

Answers (1)

Bill Nelson
Bill Nelson

Reputation: 333

You can run your executable with parameters by adding them to the end of hl.exe as you would on the command line.

system("C:\\Program Files (x86)\\Counter-Strike Condition Zero 1.2 build 2771\\hl.exe fullscreen");

where fullscreen is the parameter to run hl.exe with.

With spaces in the path you can put quotes around the string containing the executable path:

system("\"C:\\Program Files (x86)\\Counter-Strike Condition Zero 1.2 build 2771\\hl.exe\" fullscreen");

Upvotes: 10

Related Questions