Qt QProcess::execute command, in Windows cmd.exe, gives -2 exit code

232 Views Asked by At

I'm trying to invoke the Windows On-Screen Keyboard with the command:

C:\Windows\System32\osk.exe

Running this command from Windows cmd.exe works perfectly fine.

But when I run from with the Qt application

int exitCode = QProcess::execute( "c:/Windows/System32/osk.exe");

The exit code is -2.

I have also tried to wrap this within a Windows bat script and execute those as follows:

int exitCode = QProcess::execute( "cmd /c \"w:/scripts/myscript.bat\"");

And myscript.bat has:

c:\Windows\System32\osk.exe

But this gives:

'c:\Windows\System32\osk.exe' is not recognized as an internal or external command,

operable program or batch file.

1

There are 1 best solutions below

0
guest On

int exitCode = QProcess::execute("c:'\'Windows'\'System32'\'osk.exe");