QProcess::start not launching a process - qt

I need to launch an executable when I click a button inside my Qt application. To launch an executable, I am using QProcess object.
QProcess *executable = new QProcess(this);
executable->start("test.exe");
test.exe present on the same location where my Qt application exist.
The problem I am facing here is, when I am debugging, it is launching the test.exe. But when I run without debugging, it is not launching the executable. I dont know what I am missing here.

Directories in which an application tries to find test.exe are different when you run the program in debug and from Explorer. Always use full path instead.
If you place test.exe file in a folder where your application EXE is located, you can use this:
QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("test.exe")

Related

QML crashed if static build

I build static Qt 5.10.1 with mingw32.
Ref: https://github.com/arkceajin/QtDemos/blob/master/windows-build-qt-static/windows-build-qt-static.ps1
For testing purpose, build an empty QML project, it could run perfectly in QtCreator.
But if I copy the release build to another Win10&7 PC which doesn't contain the Qt environment, it will crash after the windows appeared. I'm guessing something missed inside QML.
Update:
I found No qmlscene installed appears in the Qt Versions tab, not sure it relates to the issue or not.
These two files did generate in the build folder.
projectname_plugin_import.cpp
projectname_qml_plugin_import.cpp
Found the similar issue: https://forum.qt.io/topic/42145/i-can-t-run-static-qt-qml-app-on-another-computer
Update 2:
Problem solved but I want to know why.
Here is I tried:
Connect a Win PC using remote desktop from another Win PC, run a static build QML program, then it crashed immediately after the Window appeared.
Directly login into the same local machine, run the same static build QML program, successful run.
Using the remote desktop run dynamic link QML program with Qt libs, successful run.
So the problem is Windows remote desktop, but I can't find the doc or bug report about it, if you have any idea or guessing, please help me.

Launch app converted by DAC

I've converted my app using Desktop App Converter.
Installed appx from step 1.
Launched cmd.exe and entered the following command:
"C:\Program Files\WindowsApps\MyApp_5.1.30.6486_x86__z4vxg0xscex6e\MyApp\myapp.exe"
Got the following error message: Access is denied.
Why?
What is the proper way to programmatically launch DAC converted app including any EXE inside of it?
Once installed, you can launch the app from the app list in the start menu.
If you need to be able to launch the app from a command box, you will need to declare an appExecutionAlias in the manifest, as described here:
https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-extensions#alias

Location of the program in the JDK that opens .jar files(double-click)

I would like to know the LOCATION of the .exe in the JDK that opens .jar files. What I mean is this: Which .exe in C:\Program Files\Java\jdk*version number*\jre\ opens the .jar files, so that they can be opened using a double click? I used to be able to do that, when I newly installed the JDK+JRE. Unfortunately, Nokia PC Suite has made itself the default program for opening .jar files, so that it can install them on my Symbian. Which program do I 'Open With' to get back the old functionality? I already know how to do it from the command line, but this is easier.
There is no specific program to run jar files.
It is java.exe only with the -jar option
For eg.--> java -jar "foo.jar"
Right Click on a jar file and go to its properties. Change the default opening program to java.exe.
I hope that should work.
use javaw.exe if you don't want the command window.
This convention is widely followed by others like perl/python/ruby as well.
I know how frustrating this issue is. I looked all over the internet forums before I finally found the problem...Here is the answer below :
"The root cause for the problem above is, that a program has stolen the .jar association. If you have installed the Java Runtime Environment the first time, the file type called "jar" is assigned to javaw.exe correctly. "jar" is an abbreviation for "java archive" and javaw.exe is the correct program to execute a .jar. However, on Windows any program can steal a file type at any time even if it is already associated with a program. Many zip/unzip programs prefer to do this, because a jar is stored in the .zip format. If you doubleclick on a .jar, your pack program opens the file, rather than javaw runs the program, because your pack program ignores the meta information which are also stored in a .jar."

Qt: Cannot execute '': The requested operation requires elevation

I am not able to run the application the Qt creator. It complains the following error:
Cannot execute '': The requested operation requires elevation
My .exe file has a Windows administrator shield symbol on it. Do I need to make a project settings changes? I am extensively using Qt File library for doing some file operations.
What's your executable's file name? Without an embedded manifest, windows tries to be smart and wants to run executables with "install", "update", "setup", "patch", etc. in the file name as administrator. It even checks for those names within words such as "autoupdate".
The problem is that qmake/mingw doesn't embed those manifests, while MSVC does. If someone has a clean solution to that problem, I'd be interested to learn about it.
If application you develop require administrator privileges, you cannot simply run it from Qt creator, started under non privileged account.
You can run your Qt creator as Administrtor.
Or you can start your application from QtCreator using runas utility.
But in this case you would not be able to see debug output in QtCreator console window and debug application.
If the name of the exe file has some words (update, patch, ...), the Windows UAC ask for admin privilegies. The only solution is that the project generates an exe without these words.
See this: Qt Creator create exes with admin privilegies

GUI program can't allocate a console in Qt's debugger

I have a GUI program that opens a Windows console in a separate window to display output and accept user input. My development environment is Qt 4.7.1 with mingw. The console works fine, until I try to run the program in Qt's debugger (gdb); then, although AllocConsole succeeds, and GetStdHandle appears to return a valid handle (0x000000d8), any attempt to use the handle causes Windows error 6 (invalid handle).
So I can't debug my program. Which is a pain, because it has some serious bugs. The problem may be that gdb's console prevents me opening my own console; but then why do AllocConsole and GetStdHandle succeed? I upgraded to Qt Creator 2.0.94 (Qt 4.7.1), but it didn't help. Any ideas?
Update I have found that I can debug the program by running it without the debugger, and then attaching to it from Qt. Not ideal, but better than nothing.
Can't you use the standard output console, using
CONFIG += console
in the .pro file?
Hmm -- check this out:
A process can be associated with only one console, so the AllocConsole function fails if the calling process already has a console. A process can use the FreeConsole function to detach itself from its current console, then it can call AllocConsole to create a new console or AttachConsole to attach to another console.
Can you try running FreeConsole before you create yours?

Resources