C ++运行带有参数的.exe文件 [英] c++ run .exe file with parameters

查看:140
本文介绍了C ++运行带有参数的.exe文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用C ++运行exe文件没有运气

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

我尝试过:

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

如何使用参数运行hl.exe?

How i can run hl.exe with parameters?

谢谢

更新:

'C:\Program' is not recognized as an internal or external command, operable program or batch file我收到此错误.

我尝试了system("C:\\hl.exe");,效果很好. 我认为问题出在空白

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

推荐答案

您可以通过在命令行中将参数添加到hl.exe的末尾来运行带有参数的可执行文件.

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");

其中全屏是运行hl.exe的参数.

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");

这篇关于C ++运行带有参数的.exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆