7
votes

I've been banging my head against this one for a while and I've finally caved (after a lot of searching) and have come to stack overflow for help.

As the title suggests I am trying to create an installer that can carry out a per-user install without requiring any elevated permissions.

However the following code generates a lot of ICE38 and ICE64 errors, as well as ICE91 warnings at compile time.

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="AppDataFolder">
        <Directory Id="AppRootDirectory" Name="[Manufacturer]">
          <Directory Id="INSTALLFOLDER" Name="[ProductName]" />
        </Directory>
      </Directory>
    </Directory>

    <Feature Id="ProductFeature" Title="ATestProject" Level="1">
      <ComponentGroupRef Id="modules" />
    </Feature>

"modules" refers to the contents of a heat.exe generated .wxs file whose components install directory is "INSTALLFOLDER"

The solutions available on the internet indicate a lot of editing of my modules.wxs file in order to get this to work, this is not acceptable - There are well over 1000 files in this release process and anything that cannot be automated (done on the command line at build time or with a script) is entirely out of the question.

Thanks in advance!

1
I can't read into what the errors are nor what the solutions you considered are but I think you are discarding them prematurely. A wxs file is an XML file and can therefore be automatically edited with XSL. In fact, if it is generated by heat.exe, you can pass the path to an XSL transform file and it will do the transform before emitting the output file. I routinely do this to add shortcut elements to select files, firewall exceptions, etc.Tom Blodget
@Tom This isn't very helpful as I need to know the how, I know it can be done- but my attempts at it have been fruitlessDrMattsuu

1 Answers

10
votes

You can set up a per-user install that, by default on windows 7 and later, installs to %localappdata%\Programs by doing the following;

<Property Id="ALLUSERS" Secure="yes" Value="2"/>
<Property Id="MSIINSTALLPERUSER" Secure="yes" Value="1" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="AppRootDirectory" Name="Manufacturer">
      <Directory Id="INSTALLFOLDER" Name="ProductName" />
    </Directory>
  </Directory>
</Directory>
<!-- ... -->
<!-- ... -->
<Feature Id="ProductFeature" Title="ATestProject" Level="0">
  <ComponentGroupRef Id="modules" />
</Feature>

Basically Setting the two properties at the top configures the installer to a "per user" install, which is UAC friendly and does not need elevated permissions. See This for a detailed explanation.

Please also note that ProgramFilesFolder becomes %localAppData%/programs - Microsoft's default storage place for per-user applications and installing to a users profile rather than C:\Program Files (x86)\