When I use QProcess: : startDetached opened more strange problems:
1. When the bat path there is no left parenthesis "(" , with or without blanks can open a console;
2. When the bat path there left parenthesis "(" , and existence space can open a console;
3. When the bat path there left parenthesis "(" , and there is no Spaces console a flash,
Procedure is as follows:
//a QString runPath="D: \ \ test \ \ test bat".//console open success
//a QString runPath="D: \ \ test (test \ \ test. Bat";//console open success
//a QString runPath="D: \ \ test (test \ \ test. Bat";//console flashes a
QFileInfo exeFile (runPath);
If (exeFile isFile ())
{
QString workDir=exeFile. AbsolutePath (). The replace ("/", "\ ");
Qint64 pid=0;
QDebug () & lt;QDebug () & lt; Bool pass=QProcess: : startDetached (runPath, QStringList (), workDir, & amp; Pid);
if (! Pass)//return true
{
QDebug () & lt; <"Fail".
return ;
}
}
return;
Tried to open the bat file with system, found a parenthesized will also be a flash, bother god,,,
Have a great god encountered similar problems?
CodePudding user response:
The test with the test. The bat content is as follows:
Echo "test bat file
"Pause
CodePudding user response:
CodePudding user response:
No one encountered this problem?CodePudding user response:
Direct call CMD canQString runPath="C: \ \ Windows \ \ System32 \ \ CMD exe";
The QStringList SSS;
SSS & lt; <"/k" & lt; <"D: \ \ test \ \ test bat".
Bool pass=QProcess: : startDetached (runPath, SSS);
CodePudding user response:
Before and after another path in the blank space need quotes,QString runPath="" "D: \ \ test (test \ \ test. The bat " "
CodePudding user response:
If it is a normal path by which way is no problem, I the above problem is a path with a left parenthesis has the problem, such as:
RunPath="D: \ \ test \ \ test (test). The bat".