Unsolved Open .exe file from Qt GUI
-
Hi all,I have an executable file(e.g., test.exe) run in the cmd and I must run this test.exe with administrator right, the file is not working if not run with admin right. Now I am working on to create a Qt GUI with a pushbutton, once the button clicked, the test.exe will prompt up and run. I did some online research, it says that Qprocess could do it. May I know is it possible to do it with Qprocess and is there any example could show how to do it using Qprocess. Thanks!
-
-
Hi
If you can't make a manifest for test.exe or have issues with getting runas
to display UAC dialog, then there is also
http://www.soft.tahionic.com/download-run as admin console command/index.html
which i use often to run stuff in bat/cmd files as admin.
Works like a charm and its portable and can be run from any folder. -
@Pablo-J.-Rogina
Hi, thanks for the reply. In the future need to be cross-platform, but for now, i am trying to do it in windows only.
The problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe, I not sure is it possible to do it with GUI, the command to execute test.exe will be code in the backend and once I clicked on the button, the test.exe will run it. -
@mrjj
Hi, thanks for the reply.It is similar to this code, the problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe, I not sure is it possible to do it with GUI, the command to execute test.exe will be code in the backend and once I clicked on the button, the test.exe will run it.
-
@linda said in Open .exe file from Qt GUI:
the problem is I need to open the cmd in administrator mode
That's why "runas" was suggested. Did you check this option?
-
@jsulm
I look through it and have some ideas, thanks for the reply! -
@linda
If your argument toexecute()
is actually any kind of literal string like you have typed here, it won't be right till you double those\
s. Just saying.... -
@linda said in Open .exe file from Qt GUI:
It is similar to this code, the problem is I need to open the cmd in administrator mode then go the directory and key commands to run the test.exe,
As mentioned by @JonB you don't need to 'cd' to the folder where your .exe is located. Just use the proper path to it
-
As @Pablo-J.-Rogina says, you can execute by specifying full path without worrying about
cd
-ing to change your current directory.However, if you do care about the sub-process's current directory --- e.g. if opening a file via a relative path --- you can use http://doc.qt.io/qt-5/qprocess.html#setWorkingDirectory to change the current directory for just the sub-process.
-
@JonB said in Open .exe file from Qt GUI:
@linda
If your argument toexecute()
is actually any kind of literal string like you have typed here, it won't be right till you double those\
s. Just saying....That's what QDir::toNativeSeparators is for.