Installing VC++ Redistributables in a Qt Installer Framework (QtIFW) installer?

时间秒杀一切 提交于 2019-12-05 10:26:41

I had a similar problem. You can get the systems architecture using the systeminfo.currentCpuArchitecture . To find out, whether the given architecture is x64, what I did was:

if(systemInfo.currentCpuArchitecture.search("64") < 0) {
    //x86
} else {
    //x64
}

Note: This will return the OS architecture, so a x86 OS on a x64 CPU will be seen as x86.

Edit: Have a look at: https://github.com/Skycoder42/QtIFW-Advanced-Setup . It's a sample project I created that does a lot of additional stuff to improve working with QtIFW, like for example reparing the install path or properly handling offline/online installers.

Here's the complete function I use to do this in an installscript.qt. 64 bit only. It checks for a build # less than the currently-available build (26706):

Component.prototype.installVCRedist = function()
{
    var registryVC2017x64 = installer.execute("reg", new Array("QUERY", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", "/v", "Installed"))[0];
    var doInstall = false;
    if (!registryVC2017x64) {
        doInstall = true;
    }
    else
    {
        var bld = installer.execute("reg", new Array("QUERY", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", "/v", "Bld"))[0];

        var elements = bld.split(" ");

        bld = parseInt(elements[elements.length-1]);
        if (bld < 26706)
        {
            doInstall = true;
        }
    }

    if (doInstall)
    {
        QMessageBox.information("vcRedist.install", "Install VS Redistributables", "The application requires Visual Studio 2017 Redistributables. Please follow the steps to install it now.", QMessageBox.OK);
        var dir = installer.value("TargetDir");
        installer.execute(dir + "/VC_redist.x64.exe", "/norestart", "/passive");
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!