0

So recently I've built a .msi file and I have no problem installing by double clicking on it.
However when I try to silent install it in command prompt msiexec /i product.msi /qn there will be privilege error:

Error 1303. The installer has insufficient privileges to access this directory: C:\Program Files (x86)\Company.  The installation cannot continue.  Log on as administrator or contact your system administrator.

One solution I found is set InstallScope="perMachine" under package element but it's not working for me because I'll get another privilege error

After some googling I realized I can install it with elevated command prompt, but I'm still wondering whether I can install it without elevated command prompt

below is roughly what my .wxs looks like:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Name="Product" Manufacturer="Company" Version="1.0.0"
             Id="GUID"
             UpgradeCode="GUID"
             Language="1033" Codepage="1252">
        <Package Id="*" Compressed="yes"/>
        <Condition Message="This application only support 64-bit Windows OS">VersionNT64</Condition>

        <!-- for some reason these are necessary -->
        <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
        <Property Id='DiskPrompt' Value="Acme's Foobar 1.0 Installation [1]" />

        <!-- Step 1: Define the directory structure -->
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="ProgramFilesFolderCompany" Name="Company">
                    <Directory Id="INSTALLDIR" Name="Product"/>
                </Directory>
            </Directory>
        </Directory>

        <!-- Step 2: Add files to your installer package -->
        <DirectoryRef Id="INSTALLDIR">
            <Component Id="MainExecutable" Guid="GUID">
                <File Id="MainExecutableEXE" Source="product.exe" KeyPath="yes" Checksum="yes"/>
            </Component>
        </DirectoryRef>

        <!-- Step 3: Tell WiX to install the files -->
        <Feature Id="Complete" Level="1">
            <ComponentRef Id="MainExecutable" />
            <ComponentGroupRef Id="Examples" />
            <ComponentGroupRef Id="Scripts" />
        </Feature>
    </Product>
</Wix>

Thanks for the help!

Chris Hung
  • 33
  • 1
  • 6
  • Try to run that command line non-silently from the command prompt (take out /qn) - that should give you the UAC-elevation prompt? (silent installation suppressed the prompt and a permission failure results). There are [some issues with secure properties and elevation](https://stackoverflow.com/a/49153920/129130) - essentially secure properties are not passed properly to msiexec.exe during UAC elevation. Frankly I don't recall all the details, just keep this issue in mind. What is the overall scenario for this problem to occur? – Stein Åsmul Jul 08 '20 at 14:53
  • yeah taking out `/qn` is like double click the .msi and it'll pop up a window ask for permission.(guess it's the UAC-elevation prompt you mentioned?) Not familiar with Windows OS but I imagine the scenario would be like ssh into a linux machine and install the package without UI ? – Chris Hung Jul 08 '20 at 16:51
  • Did you add a launch condition to the MSI? Look in the ***LaunchCondition table*** (if it exists). You could add the condition: ***"Privileged"*** - that might ensure a better error message? Haven't tried in ages. Perhaps the condition is there. – Stein Åsmul Jul 08 '20 at 17:33
  • [**Privileged property**](https://learn.microsoft.com/en-us/windows/win32/msi/privileged). – Stein Åsmul Jul 08 '20 at 17:45
  • 1
    If you want to install properly from a non-elevated command prompt without any fuss, you can only do that with a per-user setup targeting non-privileged locations to install (userprofile, HKCU, etc...). – Stein Åsmul Jul 08 '20 at 19:13
  • I have seen UAC settings that act like a process is elevated but it isn't. What happens if you try to create that directory manually from that elevated command prompt? – Christopher Painter Jul 09 '20 at 19:06
  • sorry for replying late, in the end we decided it's okay to run the installer in elevated prompt ... I'm gonna delete the post soon or later, but thanks for your suggestion anyway though. – Chris Hung Aug 03 '20 at 09:41

0 Answers0