Unsolved How to execute a process with QProcess
-
Hi, I have a program in my project directory which is called PsExec.exe. I wanted to execute this process with the parameter "//machine cmd.exe". I written the following code but it doesn't work:
QString program = "PsExec"; QString arguments = "\\\\"; arguments.append(f_targetComputerName); QStringList argumentList; argumentList << arguments << "cmd.exe"; QProcess *myProcess = new QProcess(this); myProcess->start(program, argumentList);
-
Hi,
What errors do you get ?
What is the final list of arguments ? -
It doesn't execute the PsExec at all. I don't know where is the problem. The final list of arguments is "//Machine cmd.exe" which I wanted to pass to PsExec.exe.
-
QProcess offers several APIs to get the output of the application you executed, its status, error informations. Did you use them ?
-
@SGaist No, I didn't use them. I know the process is executing but it doesn't show the console environment of the PsExec. I don't know where is the problem.
-
Well... Use QProcess's API to get that information.
-
Hi, maybe you forgot the -accepteula switch? Also, usually when QProcessing tricky stuff startDetached works better, say like this:
QProcess::startDetached("psexec",QStringList({"-accepteula","\\\\" + f_targetComputerName,"cmd.exe"}));