'Qt Installer Framework environment variable
How to add an Environment variable ( a directory C:/test1/bin) in System variable path( not in User variable ) using Qt Installer framework? I have tried like this,
component.addOperation ("EnvironmentVariable", "PATH","C:/testl/bin", true) ;
But this adds in User variable Path, Please help me to modify this so that the value will get added in System variable path.
Solution 1:[1]
I use the reg to solve?
if(installer.isInstaller())
{
var pathText = "D:\\test"
var reg = installer.environmentVariable("SystemRoot") + "\\System32\\reg.exe";
var RegV="HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SessionManager\\Environment"
component.addOperation("Execute", reg, "ADD", RegV , "/v", "pathText", "/t", "REG_SZ", "/d", pathText,"/f");
}
You can use the "REG ADD /?" in powershell to find the help.
Please note that this installer need call gainAdminRights():
function Component()
{
component.loaded.connect(this, this.installerLoaded);
installer.installationStarted.connect(this,Component.prototype.onInstallationStarted);
}
Component.prototype.onInstallationStarted = function()
{
installer.gainAdminRights();
installer.execute("cmd.exe", ["/c", "timeout " + "5"]);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
