Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Installer Framework -- install for non-admin user



  • Hello,

    I'm trying to figure how to install my application under a local non-admin user on Windows. If the user is also an admin, all works fine. Otherwise, the user paths are messed, the application entry is not added to Add/Remove Programs, and generally the installation is problematic. Here is my config:

    <?xml version="1.0" encoding="UTF-8"?>
    <Installer>
        <Name>MyApp</Name>
        <Version>1.0.1</Version>
        <Title>MyApp Installer</Title>
        <Publisher>MyCompany</Publisher>
        <StartMenuDir>MyApp</StartMenuDir>
        <TargetDir>@ApplicationsDirX64@/MyCompany</TargetDir>
    	<InstallerWindowIcon>installericon</InstallerWindowIcon>
    	<InstallerApplicationIcon>icon</InstallerApplicationIcon>
    	<Logo>logo.png</Logo>
    	<WizardStyle>Modern</WizardStyle>
    	<WizardDefaultWidth>820</WizardDefaultWidth>
    	<WizardDefaultHeight>440</WizardDefaultHeight>
    </Installer>
    

    And here is the script:

    function Component()
    {
        // default constructor
    }
    
    Component.prototype.createOperations = function()
    {
        component.createOperations();
    	if (systemInfo.productType === "windows") {
            component.addOperation("CreateShortcut", "@TargetDir@\\MyApp.exe", "@StartMenuDir@\\MyApp.lnk",
                "workingDirectory=@TargetDir@", "iconPath=@TargetDir@\\MyApp.exe",
                "iconId=0", "description=MyApp");
    		var createDir = ["cmd","/c","mkdir","%HOMEDRIVE%%HOMEPATH%\\AppData\\Roaming\\MyCompany\\MyApp"];
    		var deleteDir = ["cmd","/c","rmdir","%HOMEDRIVE%%HOMEPATH%\\AppData\\Roaming\\MyCompany\\MyApp","/s","/q"];
    		component.addOperation("Execute",createDir,"UNDOEXECUTE",deleteDir);
    		
    		var regargs1 = ["cmd","/c","reg add","HKEY_CURRENT_USER\\Software\\MyCompany\\MyApp"];
    		var regargs2 = ["cmd","/c","reg delete","HKEY_CURRENT_USER\\Software\\MyCompany\\MyApp","/f"];
    		component.addOperation("Execute",regargs1,"UNDOEXECUTE",regargs2);
    		component.addOperation("Execute", "{0,3010,1638,5100}", "@TargetDir@\\vc_redist.x64.exe", "/quiet", "/norestart");
    		component.addOperation("Delete", "@TargetDir@\\vc_redist.x64.exe");
    	}
    }
    

    Any help will be greatly appreciated!


Log in to reply