[QTIFW] ConsumeOutput on powershell ElevatedOperation not working
-
I am trying to create an installer for my Qt application using the Qt Installer Framework. When I attempt to use the following command with an installer without the option "Execute as an administrator":
component.addElevatedOperation("ConsumeOutput", ["openSSHInstalled","powershell.exe", "& \"" +Dir.toNativeSeparator("@TargetDir@/scripts/installOpenSSHServer.ps1")+ "\""]);I encounter the following error in the console, and my script does not run:
Warning: Cannot get any query output from executable "powershell.exe"This script installs the optional OpenSSHServer feature on Windows. Consequently, this script requires administrator rights. Therefore, I have set <RequiresAdminRights>true</RequiresAdminRights> in my XML file.
When I use the same command but with the operation set to Execute, like this:
component.addElevatedOperation("Execute", ["powershell.exe", "& \"" + Dir.toNativeSeparator("@TargetDir@/scripts/installOpenSSHServer.ps1") + "\""]);Everything runs correctly, and the OpenSSH server installation is successful. The issue is that with this command, I don't receive any feedback from the PowerShell script.
I conducted a test by launching the installer as an administrator and with the command :
component.addElevatedOperation("ConsumeOutput", ["openSSHInstalled","powershell.exe", "& \"" +Dir.toNativeSeparator("@TargetDir@/scripts/installOpenSSHServer.ps1")+ "\""]);and everything works fine. The problem is that I don't know how to enforce users to run it as an administrator, and I'm unsure if this is the correct solution. Do you have any ideas?
I think there is an issue with the "ConsumeOutput" command that consistently performs a regular "Operation" instead of an "ElevatedOperation."