0

安装程序后,我需要安装程序将程序路径添加到 Windows 系统变量 PATH。这个怎么做?

安装人员必须这样做,而不是我。

升级版:

并且程序路径也必须通过卸载删除。

UPD2:

现在我正在尝试这样做:

function Component()
{
    installer.installationFinished.connect(this, Component.prototype.installationFinishedPageIsShown);
    installer.uninstallationFinished.connect(this, Component.prototype.uninstallationFinishedPageIsShown);
}

Component.prototype.installationFinishedPageIsShown = function()
{
    try {
        if (installer.isInstaller() && installer.status == QInstaller.Success) {
            installer.executeDetached("set", "PATH=%PATH%;@TargetDir@");
        }
    } catch(e) {
        console.log(e);
    }
}

Component.prototype.uninstallationFinishedPageIsShown = function()
{
    try {
        if (installer.isUninstaller() && installer.status == QInstaller.Success) {
            installer.executeDetached("set", "PATH=%PATH:;@TargetDir@=%");
        }
    } catch(e) {
        console.log(e);
    }
}

但它不起作用:(

4

2 回答 2

0

我也为 executeDetached 函数(OS X 环境)的参数苦苦挣扎。

因为,显然,当使用字符串“内联”时,字符会被转义。对我来说,它通过将参数移动到单独的 javascript 变量来工作,例如:

var args = "PATH=%PATH:;@TargetDir@=%"
installer.executeDetached("set", args);

甚至

var args = ["PATH=%PATH:;@TargetDir@=%"]
installer.executeDetached("set", args);

没有验证,但希望它可以为您或其他人指明正确的方向。

此外,将 executeDetached 包装在 console.log() 中帮助我调试了很多!

于 2017-08-08T08:45:56.960 回答
-1

在桌面上,右键单击计算机图标。从上下文菜单中选择属性。单击高级系统设置链接。单击环境变量。... 在编辑系统变量(或新系统变量)窗口中,指定 PATH 环境变量的值。

于 2017-03-30T07:49:11.133 回答