WIX Change the default Install Path

2019-09-16 05:01发布

问题:

I am trying to change the default install path to User's Home directory/ProductName.

Below is my code(its not the entire code)

<Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" Description="desc" Comments="View Violations in APD" InstallPrivileges="elevated"/>

<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"/>
<Property Id="ENVIRONMENT" Secure="yes" />
<UIRef Id="WixUI_InstallDir" />
<UIRef Id="WixUI_ErrorProgressText" />

<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
  <Component Id="InstallScripts"  Guid="someGUID">        
    <File Id="file1.il" Source="$(var.ScriptsFolder)\file1.il"/>
    <File Id="file2.il" Source="$(var.ScriptsFolder)\file2.il"/>
  </Component>
</DirectoryRef>    
<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
        <Directory Id="ProgramMenuSubfolder" Name="CompanyName">
          <Directory Id="ScriptsFolder" Name="SoftwareName" />
          <Directory Id="INSTALLFOLDER" Name="SoftwareName" />

            <Component Id="Registry_FriendlyName">
                <RegistryValue Id="RegKey_FriendlyName" Root="HKCU"
                       Key="Software\Microsoft\Office\Excel\AddIns\AddIn1"
                       Name="FriendlyName"
                       Value="AddIn1"
                       Type="string" KeyPath="yes" />
            </Component>            
            <Component Id="Registry_Manifest" Guid="SomeGUID">
                <RegistryKey Root="HKCU" Key="Software\Microsoft\Office\Excel\AddIns\AddIn1" Action="create">
                    <RegistryValue Id="RegKey_Manifest" Name="Manifest" Type="string" Value="[INSTALLFOLDER]ViolationsAddIn.vsto|vstolocal" KeyPath="yes" />              
                </RegistryKey>            
            </Component>
            <Directory Id="GAC" Name="GAC">            
                <Component Id="dll_gac_Component" DiskId="1" Guid="SomeGUID">
                  <File Id="Core_dll_gac" KeyPath="yes"
                        Name="Core.dll" Source="$(var.variable1)"  Assembly=".net"></File>
                </Component>
            </Directory>
        </Directory>
    </Directory>
</Directory>

If you see above code.. right now the default path is InstallFolder which is SoftwareName folder. I am using this InstalFolder in few more places to copy few files (DirectoryRef), adding registry values etc. Now I would like to set the default install path to Users Home Directory and users can change it to anything else without breaking these features. Please help me.

Any help is appreciated.

Thanks

回答1:

In addition to ProgramFilesFolder, there are many standard system folder properties.

You'll notice that the folder you indicate (user's profile folder) is not a defined folder in Windows Installer. The reason is that the operating system designers have a lot of goals in mind when they create profile layouts for each operating system release. One of which is anticipating that users will want some data copied from computer to computer as they log into different computers in a domain (roaming profile). And, they'll want other data not to be copied.

To install software under this design, you have to know if you want it roaming or not, and then select an installation folder appropriately. Look at AppDataFolder and LocalAppDataFolder.