QT QProcess, WinExec, ShellExecute中文路径带空格程序或者脚本执行并带参数
一. QProcess, WinExec, ShellExecute三种方式:
1.WinExec 不支持中文路径,程序无法启动,参数最少(简单使用, 复杂不建议)。
2.QProcess 执行exe程序带参数,中文路径需要传入"\"",否则路径无法识别。(执行exe)
3.ShellExecute 执行bat脚本带参数,执行权限等会与宿主脚本或者程序一致。(执行脚本)
二. 使用方式:
1.winExec使用最简单:
std::string path = "C:/test/test.exe"
WinExec(path.c_str(), SW_HIDE);
2.QProcess 使用:
if(m_process == nullptr) {m_process = new QProcess(this);}// 启动程序QStringList argments;argments << m_installPath << "/VERYSILENT" << "/SUPPRESSMSGBOXES" << "/NOREST