-1

i'm trying to run a batch file using qt, the batch file is using nircmd.exe program and looks like this:

@echo off
nircmd setprimarydisplay 2
timeout /t 10
nircmd setprimarydisplay 1
exit

and i'm trying to run this line in QT:

QProcess::startDetached("cmd", QStringList() << "/c" << "C:\\Users\\User\\Desktop\\tmp.bat");

when i'm running my QT code it says "'nircmd' is not recognized as internal or external command, operable program or batch file."

The nircmd.exe is located in c:\windows\system32, the the computer path is detecting to the right spot.

What could be the problem?

Thanks

biramb
  • 11
  • 1
  • 3

1 Answers1

0

I have figure it out, the problem was in the .bat file it supposed to look like this:

c:\windows\system32\nircmd setprimarydisplay 2
biramb
  • 11
  • 1
  • 3
  • `c:\windows\system32` should be in your path. If this solves your problem, you're having issues with the `PATH` environment variable. Try printing it in the batch file to figure out what it contains. – isanae Aug 23 '16 at 15:03
  • the PATH wasn't the problem. when you try to run a bat file from qt or cmd commands it could make a problem and not be able to find nircmd(in this case) bacause my OS is 64 bit, so it looking for nircmd.exe in c:\windows\sysWOW64 instead – biramb Aug 24 '16 at 06:53