Plenty of questions regarding this issue but none of them explain where exactly those two lines should be placed:
<Property Id="ARPNOREPAIR" Value="yes" Secure="yes" />
<Property Id="ARPNOMODIFY" Value="yes" Secure="yes" />
Tried searching online, on the documentation itself but no luck
EDIT
I tried putting them inside my tag but it's still there:
I ran into this same issue today and the accepted answer did not hide the Options button or disable the Repair button in my WiX standard boostrapper.
To hide/disable the Options and Repair buttons in a WixStandardBootstrapperApplication first add the BalExtension namespace (top of your Bundle.wxs):
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
Then in the BootstrapperApplicationRef element add the SuppressOptionsUI and SuppressRepair attributes setting both to yes.
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication LicenseFile="YourLicense.rtf"
LogoFile="YourLogo.png"
SuppressOptionsUI="yes"
SuppressRepair="yes" />
</BootstrapperApplicationRef>
You need to place them within the Product tags in your Product.wxs file.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<!-- TODO: Put your code here. -->
<Product>
<!-- Place them here. -->
<Property Id="ARPNOREPAIR" Value="yes" Secure="yes" />
<Property Id="ARPNOModify" Value="yes" Secure="yes" />
</Product>
</Fragment>
</Wix>
After you've run your MSI and install your application you should see the following window if you execute your MSI again:
As you can see, the options in Programs and Features will also be disabled.
Related
I'm new to WiX and am currently learning. It has quite the learning curve. I'm currently getting the error below:
Severity Code Description Project File Line Suppression State
Error Duplicate symbol 'Media:1' found. This typically means that an Id is duplicated. Check to make sure all your identifiers of a given type (File, Component, Feature) are unique. SetupProject1 \\Mac\Home\Desktop\myFolder\HelloWorld\SetupProject1\Product.wxs 12
I don't quite understand why I'm getting this error. If i change the Media Id="1" in the line <Media Id="1" Cabinet="simple.cab" EmbedCab="yes"/> to Media Id="2", the code seems to work. I don't understand because none of my other Id's have a 1 in them and yet I am still getting this error.
Also, if anyone happens to know what this line does: <Property Id="ADDINFOLDERFOUND" Value="NO" /> feel free to enlighten me, I didn't find anything in the docs about it.
Here is my code:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define HelloWorld_TargetDir=$(var.HelloWorld.TargetDir)?>
<Product Id="xxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxx"
Name="HelloWorldTestProject"
Language="1033" Version="1.0.0.0"
Manufacturer="testManufacturer"
UpgradeCode="xxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxx">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Comments="This is the commemnts section" />
<Media Id="1" Cabinet="simple.cab" EmbedCab="yes"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." Schedule="afterInstallInitialize" AllowSameVersionUpgrades="yes" />
<MediaTemplate />
<Property Id="ADDINFOLDERFOUND" Value="NO" />
<!--not sure what this line does-->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"/>
<UIRef Id="MyWixUI_InstallDir" />
<!--Add or remove programs properties-->
<!--Application Icon-->
<Icon Id="icon.ico" SourceFile="resources\SetupIcon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Directory Id="TARGETDIR" Name="SourceDir">
<!-- </Component> -->
<Component Id="HelloWorld.addin" Guid="xxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxx">
<File Id="HelloWorld.addin" Name="HelloWorld.addin" Source="$(var.HelloWorld_TargetDir)HelloWorld.addin" />
</Component>
<Component Id="HelloWorld.dll" Guid="xxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxx">
<File Id="HelloWorld.dll" Name="HelloWorld.dll" Source="$(var.HelloWorld_TargetDir)HelloWorld.dll" />
</Component>
</Directory>
<InstallExecuteSequence> <!-- Still working on figuring this out -->
</InstallExecuteSequence><!-- Still working on figuring this out -->
<InstallUISequence> <!-- Still working on figuring this out -->
</InstallUISequence> <!-- Still working on figuring this out -->
</Product>
</Wix>
Any help/direction is appreciated.
The MediaTemplate tag is redundant, remove it or comment it out and you should be good to go.
Property Id="ADDINFOLDERFOUND" Value="NO" is a custom property and from the code you posted, I don't see it being used.
See also: What is the difference between Media and MediaTemplate in WIX?
Hope this helps!
I've followed the official Major Upgrade guide and I seem to be missing something.
Here is my MCVE:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Codepage="1252" Language="1033" Manufacturer="Bla Corporation"
Name="Bla" UpgradeCode="PUT-GUID-HERE" Version="31.00.0000">
<Package Comments="Contact: Refael Sheinker, refael.sheinker#bla.com." Description="Bla"
InstallerVersion="500"
Compressed="yes"
InstallScope="perMachine"
Keywords="Installer,MSI,Database" Languages="1033" Manufacturer="Bla Corporation" Platform="x64" />
<Media Id="1" Cabinet="my_application.cab" EmbedCab="yes" />
<MajorUpgrade AllowDowngrades="no"
AllowSameVersionUpgrades="no"
Disallow="no"
IgnoreRemoveFailure="no"
MigrateFeatures="yes"
Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed" />
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONROOTDIRECTORY" />
<UIRef Id="WixUI_InstallDir" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="PROGRAMFILESSUBDIR" Name="Bla">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="BlaInternal" />
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Component Id="tenlira.ini" Guid="*">
<File Id="tenlira.ini" Source="..\ConfigurationFile\x64\tenlira.ini" KeyPath="yes" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="TenLira" Level="1">
<ComponentRef Id="tenlira.ini" />
</Feature>
</Product>
</Wix>
All it does is simply installing a single file as an example. So far, so good. Now, all I do is add another Component and File and off course the corresponding ComponentRef in Feature. I specifically leave the Version as is: 31.00.0000. What I expected is that the new installer will not perform a Major Upgrade, but it does. Why? Also, there is now 2 entries in Add/Remove Programs.
Please help me find out what am I missing here. Thanks. Refael.
UPDATE:
Posting the question got me to reread the documentation again and I discovered that the AllowSameVersionUpgrades thingy in the MajorUpgrade element should be set to yes. This time there is only one entree in the Add/Remove Programs, but it still performs Major Upgrade. Why?
UPDATE: Here is a list to help debug failing major upgrades by identifying the most common problems: Common causes of failed major upgrades
Major Upgrade - "The Old, Manual Way"
I guess you are hitting an oddity that may not be handled entirely as expected by the WiX MajorUpgrade element by combining the auto-generated product GUID, the AllowSameVersionUpgrades set to yes and keeping the version number the same.
I can't see any obvious way to set the MinInclusive attribute in WiX's MajorUpgrade element - I could be mistaken, there might be a way I am unaware of. For what it is worth, I am not too keen on allowing "same version upgrades".
However, you could try to "use the old way" to author the Upgrade table using the "older elements" Upgrade and UpgradeVersion. The MajorUpgrade element is essentially a "convenience" feature to set up your major upgrades easily, and I believe it works for most users. Bob Arnson has a blog explaining the introduction of the MajorUpgrade element. This blog also shows a sample of how to do things "manually" with the "older elements" Upgrade and UpgradeVersion (do check it out).
I made a quick mock-up that might do what you want, it is just a "rough draft" - can't make any guarantees. I use preprocessor defines to set some variables that can be referenced in the WiX source file - as a C++ developer this is a piece of cake for you so I won't waste time explaining it - the source should make sense:
<?define MyProductVersion = "31.00.0000" ?>
<?define MyProductCode = "PUT-GUID-HERE" ?>
<?define MyUpgradeCode = "PUT-GUID-HERE" ?>
<!--Recommendation: set a path variable that you can redirect at will to a new release folder (new build output folder): -->
<!-- <?define MyBasePath = "C:\Projects\MyApp\Release\31.00.0000\" ?> -->
<!-- SAMPLE:
<Component Win64="yes" Feature="MainApplication">
<File Source="$(var.MyBasePath)\myapp.exe" />
</Component> -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="$(var.MyProductCode)" Codepage="1252" Language="1033" Manufacturer="Bla Corporation"
Name="Bla" UpgradeCode="$(var.MyUpgradeCode)" Version="$(var.MyProductVersion)">
<Package Comments="Contact: Refael Sheinker, refael.sheinker#bla.com." Description="Bla"
InstallerVersion="500"
Compressed="yes"
InstallScope="perMachine"
Keywords="Installer,MSI,Database" Languages="1033" Manufacturer="Bla Corporation" Platform="x64" />
<Media Id="1" Cabinet="my_application.cab" EmbedCab="yes" />
<!-- Major upgrade -->
<Upgrade Id="$(var.MyUpgradeCode)">
<!-- Downgrade Protection -->
<UpgradeVersion Minimum="$(var.MyProductVersion)" OnlyDetect="yes" IncludeMinimum="yes" Property="DOWNGRADE_DETECTED" />
<!-- Major Upgrade Configuration -->
<UpgradeVersion IncludeMinimum="no" Maximum="$(var.MyProductVersion)" IncludeMaximum="no" MigrateFeatures="yes" Property="UPGRADE_DETECTED" />
</Upgrade>
<!-- Major Upgrade: Schedule RemoveExistingProducts -->
<InstallExecuteSequence>
<!-- Potential scheduling (after): InstallValidate, InstallInitialize, InstallExecute, InstallExecuteAgain, InstallFinalize -->
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
<!--Launch Condition: Abort setup if higher version found-->
<Condition Message="!(loc.NewerVersionDetected)">
NOT DOWNGRADE_DETECTED
</Condition>
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONROOTDIRECTORY" />
<UIRef Id="WixUI_InstallDir" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="PROGRAMFILESSUBDIR" Name="Bla">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="BlaInternal" />
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Component Id="Test.ini" Guid="PUT-GUID-HERE" Win64="yes" Feature="MainApplication">
<CreateFolder Directory="APPLICATIONROOTDIRECTORY" />
<IniFile Id="SomeSetting" Action="addLine" Directory="APPLICATIONROOTDIRECTORY" Key="Setting1" Name="Test.ini" Section="MySection" Value="Some Setting" />
<IniFile Id="OtherSetting" Action="addLine" Directory="APPLICATIONROOTDIRECTORY" Key="Setting2" Name="Test.ini" Section="MySection" Value="Other Setting" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="TenLira" Level="1">
<!--<ComponentRef Id="tenlira.ini" />-->
</Feature>
</Product>
</Wix>
Now the !(loc.NewerVersionDetected) has to be explained. This is a localized string (for delivering your setup in different languages). To use it, right click your WiX project in Visual Studio and go: Add New Item... => Localization File => Add. As the localization file is added, your output MSI will also now go into a en-us folder under your main output location (Debug or Release).
In the localization file, add:
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="NewerVersionDetected">A later version of [ProductName] is already installed.</String>
</WixLocalization>
And you should now be able to add new strings to this file and easily translate your whole setup using such language files.
Also add the WiX GUI extension. Right click "References". Add Reference... => Browse to WixUIExtension.dll => Double click this file, and press OK. Normal folder to find the file is: C:\Program Files (x86)\WiX Toolset v3.11\bin.
INI-Files
I just want to mention that INI files should ideally be installed via the IniFile table (entries are treated as atomic key-value pairs allowing advanced merging of keys and values for existing INI files), and not via the File table (the file is treated as a regular file either overwriting the whole existing file or leaving it in place - not enforcing any new values). The WiX element corresponding to the MSI IniFile table is naturally the IniFile element.
An ad-hoc sample:
<Component Id="Test.ini" Guid="PUT-GUID-HERE" Win64="yes" Feature="MainApplication">
<CreateFolder Directory="APPLICATIONROOTDIRECTORY" />
<IniFile Id="SomeSetting" Action="addLine" Directory="APPLICATIONROOTDIRECTORY" Key="Setting1" Name="Test.ini" Section="MySection" Value="Some Setting" />
<IniFile Id="OtherSetting" Action="addLine" Directory="APPLICATIONROOTDIRECTORY" Key="Setting2" Name="Test.ini" Section="MySection" Value="Other Setting" />
</Component>
Links:
Adding entries to MSI UpgradeTable to remove related products
It does a major upgrade because both MSIs have the same UpgradeCode and you have now specified AllowSameVersionUpgrades, so it does the upgrade where it didn't before.
Your build generates a new ProductCode every time, so each MSI is a new product, so you will get it installed twice if it doesn't do an upgrade and once if it does. You may have some assumption about the way upgrades work that you haven't spelled out.
I had the same problem where Version is same, but the Id is different creating multiple entries in Add/Remove programs.
My simple fix was to set AllowSameVersionUpgrades="yes".
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of $(var.ServiceName) is already installed." />
I am using Wix to create my installer.
According to the official documentation, if I want to change the icon in Add/Remove Programs, I need to add this:
<Icon Id="icon.ico" SourceFile="MySourceFiles\icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
But it does not works, the icon is not changed and I also get the following warning:
C:\Users\rsheink\home\repos\tenlira\10Lira\TestWiXProject\Product.wxs(137,0):
warning LGHT1076: ICE36: Icon Bloat. Icon icon.ico is not used in the
Class, Shortcut, or ProgID table and also not used for ARPPRODUCTICON
property.
What am I missing please?
Thanks. Refael.
Edit:
Following the excelent advice from #harper, here is the MCVE:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:difx="http://schemas.microsoft.com/wix/DifxAppExtension">
<Product Id="*" Codepage="1252" Language="1033" Manufacturer="Intel Corporation"
Name="TenLira" UpgradeCode="PUT-GUID-HERE" Version="31.00.0000">
<Package Comments="Contact: Your local administrator" Description="TenLira" InstallerVersion="500"
Compressed="yes"
InstallScope="perMachine"
Keywords="Installer,MSI,Database" Languages="1033" Manufacturer="Intel Corporation" Platform="x64" />
<Media Id="1" Cabinet="my_application.cab" EmbedCab="yes" />
<MajorUpgrade AllowDowngrades="no"
AllowSameVersionUpgrades="no"
Disallow="no"
IgnoreRemoveFailure="no"
MigrateFeatures="yes"
Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed" />
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONROOTDIRECTORY" />
<UIRef Id="WixUI_InstallDir" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="PROGRAMFILESSUBDIR" Name="Intel Corporation">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="TenLira">
<Directory Id="kmgl" Name="kmgl">
<Directory Id="kmgl_win10" Name="kmgl_win10" />
</Directory>
<Directory Id="tools" Name="tools" />
</Directory>
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="tools">
<Component Id="devcon.exe" Guid="*">
<File Id="devcon.exe" Source="..\tools\devcon\amd64\devcon.exe" KeyPath="yes" />
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="TenLira" Level="1">
<ComponentRef Id="devcon.exe" />
</Feature>
<!--It should set the icon in Add/Remove programs, but it does not works and I don't know why.-->
<Icon Id="icon.ico" SourceFile="..\TenLira icons\coins\coins.ico" />
<Property Id="ARPPRODUCTION" Value="icon.ico" />
</Product>
</Wix>
Request: Please comment if any of the below works for you - and also if you did something else (as well) to get things working.
Quick List First:
Is ARPPRODUCTICON spelled correctly?
Does the File.ico file have a hidden file extension? Example: icon.ico.bmp - 1.
Show file extensions in Windows Explorer
Open a cmd.exe in the folder and do a dir to check?
Icon file problems:
Is that a proper *.ico file? Try to save a normal *.bmp and rename the extension to *.ico. That should work for a rudimentary test icon.
Find a proper template *.ico file for testing (there should be plenty
in your Visual Studio installation folder).
UPDATE:
Please try to change this:
<Property Id="ARPPRODUCTION" Value="icon.ico" />
into this:
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
I will leave the original answer below since the setup.exe issue might be relevant for others.
And one more thing: I was told that the dialog set <UIRef Id="WixUI_Mondo" /> is the better one in the available WiX templates. I have no hard facts apart from that recommendation though. I haven't used <UIRef Id="WixUI_InstallDir" /> - just if it can save you some time.
Old Answer:
This might just be a uppercase / lowercase issue. As in icon.ico instead of Icon.ico.
Correct:
<Icon Id="Icon.ico" SourceFile="MySourceFiles\Icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="Icon.ico" />
Wrong:
<Icon Id="icon.ico" SourceFile="MySourceFiles\icon.ico"/>
<Property Id="ARPPRODUCTICON" Value="Icon.ico" />
During my testing I get the warning though, but the icon does work in Add/Remove Programs either way. Are you making a setup.exe bundle?
When you make a setup.exe bootstrapper bundle, you have to set the IconSourceFile attribute of the Bundle Element.
A link for safekeeping: How to customize icon for Wix custom bootstrapper.
I have the below Wix XML code that I have written for Single Package Authoring. The problem is when "Install for all unders of this machine" mode is selected in the UI(WixUI_Advanced), the default location that shows up in the UI is "C:\Users\XXXX\AppData\Local\Programs\MyApp\ ". How can I change this, so that the default location is ..\Program Files (x86)\MyApp....
If I change <Property Id="MSIINSTALLPERUSER" Value=" "/>,
then the default location is ..\Program Files(x86).., but the per user does not work due to lack of admin privileges.
Much appreciated.
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<!--Product Information-->
<Product Id="*"
Name="$(var.ApplicationName)"
Language="1033" Version="!(bind.FileVersion.$(var.ExecutableName))" Manufacturer="$(var.ManufacturerName)"
UpgradeCode="33bc2348-****-****-****-ebcde0d14afe">
<!--MSI Package Information-->
<Package InstallerVersion="500"
Compressed="yes" />
<!--Single Package Authoring-->
<Property Id="MSIINSTALLPERUSER" Value="1"/>
<Property Id="ALLUSERS" Value="2"/>
<!--Upgrade Information-->
<MajorUpgrade DowngradeErrorMessage="A newer version of $(var.ApplicationName) is already installed." />
<MediaTemplate EmbedCab="yes" />
<!--Application Features-->
<Feature Id="CoreFeature" Title="$(var.ApplicationName)" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="RegisterApplicationAutoStart" />
</Feature>
<!--Required .NET Framework for the Application-->
<PropertyRef Id="NETFRAMEWORK35" />
<Condition Message="This application requires Microsoft .NET Framework 3.5 or greater. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK35]]>
</Condition>
<!--Advanced UI-->
<Property Id="ApplicationFolderName" Value="$(var.ApplicationName)" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<UIRef Id="WixUI_Advanced"/>
<InstallExecuteSequence>
<Custom Action="LaunchApplication" After="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<!-- Define the Target Directory. The individual files will be filled in via a Heat generated fragment. -->
<Directory Id="TARGETDIR" Name="SourceDir">
<!--Define the directory when the application will be installed-->
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONFOLDER" Name="$(var.ApplicationName)" />
</Directory>
</Fragment>
<Fragment>
<Component Id="RegisterApplicationAutoStart" Directory="ApplicationProgramsFolder" Guid="*">
<RegistryValue Root="HKMU"
Key="Software\Microsoft\Windows\CurrentVersion\Run"
Name="$(var.ApplicationName)"
Type="string"
Value="[APPLICATIONFOLDER]$(var.ExecutableName)"
KeyPath="yes" />
</Component>
</Fragment>
</Wix>
The OP described it perfectly. With single authoring enabled in the following way, there seems to be no way to obtain to "actual" ProgramFilesFolder at C:\Program Files (x86)\.
<Package InstallerVersion="200" ... /> <!-- do not specify InstallScope or InstallPrivileges! -->
<Property Id="ALLUSERS" Value="2" />
<Property Id="MSIINSTALLPERUSER" Value="1" />
Even if MSIINSTALLPERUSER is reset, this does not change the value of ProgramFilesFolder, it's still C:\Users\XXX\AppData\Local\Programs (I assume the folder is initialised through SHGetFolderPath at installer startup, and doesn't change thereafter).
Setting the ProgramFilesFolderexplicitly like the OP showed in his answer would work I guess, but it's an ugly hack. What worked for me in the end was to start out in 'perMachine'-Mode:
<Property Id="ALLUSERS" Value="2" />
<Property Id="MSIINSTALLPERUSER" />
Afterwards, if the installer chooses the 'perUser'-Mode, I set the variables accordingly:
<Publish Dialog="MyWelcomeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="1">1</Publish>
<Publish Dialog="MyWelcomeDlg" Control="Next" Property="ALLUSERS" Value="{}">1</Publish>
This way, the folders will be correctly set.
I consider the underlying problem to be that ProgramFilesFolder would ever get set to something in AppData, that makes little to no sense.
If you want to install to the Program Files folder then you are required to be administrator. Limited users cannot create or update files in that folder, and running an MSI install does not break security just because it's an install. So the answer is that you cannot install to ProgramFiles unless you cause the MSI to ask for elevated privileges. Your question is essentially "how can a limited user break security by adding or replacing files in the Program Files folder", and there's no way to answer that.
Does your app require elevated privileges to run? Does it have an elevation manifest? If the answer is yes, then I suspect you're stuck with the requirement that elevated privileges are also needed to install it.
I included the below line in the WiX installer that fixed my issue.
<SetDirectory Id="ProgramFilesFolder" Value="C:\Program Files (x86)\"></SetDirectory>
This changed the value of ProgramFilesFolder that was being set to C:\Users\XXX\AppData\Local..... to C:\Program Files (x86) for per machine installation.
Also the above line of code does not make any difference to per user installation and installation happens at that user folder only (as desired.)
Please follow the link below
http://wixtoolset.org/documentation/manual/v3/wixui/dialog_reference/wixui_advanced.html
For a per-machine installation, the default installation location will be
[ProgramFilesFolder][ApplicationFolderName]
and the user will be able to change it in the setup UI.
For a per-user installation, the default installation location will be
[LocalAppDataFolder]Apps[ApplicationFolderName]
and the user will not be able to change it in the setup UI.
you can set the per user to 0 to enforce installation per machine - or in Program files
<WixVariable Id="WixUISupportPerUser" Value="0" />
For per-machine installation you will need admin privileges, if the user will not have admin privileges, he only has access to his local app data folder, hence that location cannot be changed.
I am trying to create an MSI using WIX and I seem to have stumbled across a small issue that is confusing me a bit in regards to the upgrade. I have followed about 3 tutorials on the subject and each one gives me the same result. When I try to upgrade the application I get a generic
Another version of this product is already installed.
message. After looking around I saw that in order to successfully upgrade I need to specify a new Product GUID. This seemed odd to me because the main WiX website said that that is only needed for major installs. Since I wasn't getting much luck I decided to go with it. Lo and behold it successfully executed the installer, but when I checked in Add/Remove Programs I now had 2 copies of the application installed. This is driving me crazy. Please see the below .wxs and please show me my errors where applicable.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="PRODUCT-GUID-GOES-HERE-B86BCC79EEFD" Name="Sample Application" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Sample Inc." UpgradeCode="$(var.UpgradeCode)">
<Package Id="*" Keywords="Installer" Platform="x64" InstallerVersion="200" InstallPrivileges="elevated" InstallScope="perMachine" Compressed="yes" />
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" Language="1033" Property="NEWPRODUCTFOUND" />
<UpgradeVersion Minimum="$(var.RTMProductVersion)" IncludeMinimum="no" Maximum="$(var.ProductVersion)" IncludeMaximum="no" Language="1033" Property="UPGRADEFOUND" />
</Upgrade>
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="Sample" Name="Sample">
<Directory Id="INSTALLLOCATION" Name="Sample Application">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="SampleApplication" Guid="APPLICATION-GUID-GOES-HERE-c7247f5d1b42" Win64="yes">
<!-- TODO: Insert files, registry keys, and other resources here. -->
<File Id="SampleEXE" Name="Sample.exe" Source="Sample.exe" ProcessorArchitecture="x64" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<Feature Id="Complete" Title="sample64" Level="1">
<!-- TODO: Remove the comments around this ComponentRef element and the Component above in order to add resources to this installer. -->
<ComponentRef Id="SampleApplication" />
<!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. -->
<ComponentGroupRef Id="Product.Generated" />
</Feature>
<CustomAction Id="NoDowngrade" Error="A later version of [ProductName] is already installed." />
<InstallExecuteSequence>
<Custom Action="NoDowngrade" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
<RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="NoDowngrade" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
</InstallUISequence>
</Product>
</Wix>
Thanks in advance for any help.
Set Product/#Id to "*" to get automatic product code changes and use the MajorUpgrade element. For more context, see my blog.