i have following condition for wix installer:
- Starting Installer directory for install should be RootDirectory\ApplicationName [C:\MYApplication]
- User should able to customize this path (using pathedit or any textbox )
I've done following code but problem is half of installation is done at specified path and half of folder is copied in the root directory.
<Fragment>
<Property Id="_BrowseProperty" Value="INSTALLDIR" Secure="yes"/>
<CustomAction Id="SetDataLocationDefault" Property="INSTALLDIR" Value="[WindowsVolume]$(var.Title)\" />
<InstallUISequence>
<Custom Action="SetDataLocationDefault" After="CostFinalize" />
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="SetDataLocationDefault" After="CostFinalize" />
</InstallExecuteSequence>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLDIR" Name="$(var.Title)">
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="$(var.Title)"/>
</Directory>
</Directory>
<Directory Id="DesktopFolder"/>
</Directory>
Another file for the component includes
<Fragment>
<ComponentGroup Id="ProductInstallComponent">
<ComponentRef Id="EXEPackage" />
<ComponentRef Id="ProjectsOutput" />
<ComponentRef Id="TempReports" />
<ComponentRef Id="Help" />
<ComponentRef Id="ApplicationShortcut" />
<ComponentRef Id="ApplicationDeskShortcutComp" />
</ComponentGroup>
in the case Help Files and Report Files are created at the rootlocation. so how can i change that?
AFAIK such an action has to be set before the CostFinalize-action, as afterwards all the directories are set and unmutable. Also set it in both sequences, as you already did in the example above. I.e. it should be the following:
<InstallUISequence>
<Custom Action="SetDataLocationDefault" Before="CostFinalize" />
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="SetDataLocationDefault" Before="CostFinalize" />
</InstallExecuteSequence>
Related
I'm using wix to create an installer for my application in Visual Studio.
I need a post-install executable run after install (which I've got working) and a pre-uninstall executable run before uninstallation.
All of these executables require elevated rights to run (my application, the post-install, and pre-uninstall).
I've scoured the web and stack overflow and found many posts related to this, but none of the solutions seem to work. Either the executables simply don't run, or, on uninstall I get error
There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor.
Here is my Directory layout
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ROOTDIRECTORY" Name="MyCompany" >
<Directory Id="FOLDERONE" Name="FolderOne" />
<Directory Id="UTILITYFOLDER" Name="Utility" />
</Directory>
</Directory>
</Directory>
</Fragment>
And a snippet of my File layout
<Fragment>
<DirectoryRef Id="UTILITYINSTALLFOLDER">
<Component Id="cmpPreInstallId" Guid="{56DC3D0A-E887-4A94-95B3-72825310DC5D}">
<File Id="filPreInstallId" KeyPath="yes" Source="path_to\PreUninstall.exe" />
</Component>
<Component Id="cmpPosUninstallId" Guid="{DE1DE45E-4D7C-4884-BA3E-EC078E265B7C}">
<File Id="filPostUninstallId" KeyPath="yes" Source="path_to\PostInstall.exe" />
</Component>
<!-- obviously there are other files/components -->
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="UtilityPublishedComponents">
<ComponentRef Id="cmpPreInstallId" />
<ComponentRef Id="cmpPosUninstallId" />
</ComponentGroup>
</Fragment>
And in my Product.wxs
<Product ...>
<!-- The only way I found that actually worked to run the post install was -->
<UI>
<UIRef Id="WixUI_Minimal" />
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="PostInstallExe">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Perform post-install operations." />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1"/>
<Property Id="WixShellExecTarget" Value="[#filPostUninstallId]" />
<CustomAction Id="PostInstallExe"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
<!-- this does not work to run the pre-uninstall -->
<CustomAction Id="EXECUTE_BEFORE_UNINSTALL"
Return="check"
Impersonate="yes"
Execute="immediate"
Directory="UTILITYINSTALLFOLDER"
ExeCommand="PreUninstall.exe" />
<InstallExecuteSequence>
<Custom Action="EXECUTE_BEFORE_UNINSTALL" Before="RemoveFiles">Installed AND NOT REINSTALL</Custom>
</InstallExecuteSequence>
<!-- other stuff plus the feature -->
</Product>
Anyone with experience see where this might be going wrong?
I've tried many variations of the CustomAction return, impersonate, execute, etc
Finally got it to work, so hopefully this helps someone.
Not sure what the issue was ... but here!
<!-- Setup post install operations -->
<CustomAction Id="PostInstall"
FileKey="key_to_post_install_exe"
ExeCommand=""
Execute="deferred"
Return="check"
Impersonate="no" />
<!-- Setup pre uninstall operations -->
<CustomAction Id="PreUninstall"
FileKey="key_to_pre_uninstall_exe"
ExeCommand=""
Execute="deferred"
Return="ignore"
Impersonate="no" />
<!-- Add pre and post install operations to the installer -->
<InstallExecuteSequence>
<Custom Action="PostInstall" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="PreUninstall" After="InstallInitialize">Installed</Custom>
</InstallExecuteSequence>
I'm making installer with WiX 3.10. My original task is to copy Postgres files to target system, initialize cluster, register service, start it and restore database on install, and in reverse - stop service, remove it from system, and clear up cluster data. I wrote two bat files, and added custom actions to execute them and some conditions as described in various places, but none of them working. I've tried with and without CDATA, Installed, INSTALLED and some other variations, but it always executes both actions.
Here is the wix file I'm experimenting with now.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Hatred_6" Language="1033" Version="1.0.0.0" Manufacturer="Satan" UpgradeCode="d9602b10-8428-4031-8c82-99288b21377f">
<Package InstallerVersion="405" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<CustomAction Id="AAction" Directory="INSTALLFOLDER" Execute="deferred" Impersonate="no" Return="check"
ExeCommand="cmd.exe /c "a.bat"">NOT Installed</CustomAction>
<CustomAction Id="BAction" Directory="INSTALLFOLDER" Execute="deferred" Impersonate="no" Return="check"
ExeCommand="cmd.exe /c "b.bat"">Installed</CustomAction>
<InstallExecuteSequence>
<Custom Action="BAction" After="InstallFiles" />
<Custom Action="AAction" After="InstallFiles" />
</InstallExecuteSequence>
<Feature Id="ProductFeature" Title="Hatred_6" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Hatred_6" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="CalcComponent" Guid="515C0606-FD73-4B5D-ACF4-481123092A3E">
<File Id="CalcFile" KeyPath="yes" Source="calc.exe" />
</Component>
<Component Id="AComponent" Guid="515e3aa0-e5a0-4cd1-aaa5-ebf25a679a24">
<File Id="AFile" KeyPath="yes" Source="a.bat" />
</Component>
<Component Id="BComponent" Guid="85f7627e-fc39-4f78-a870-221d2d08375d">
<File Id="BFile" KeyPath="yes" Source="b.bat" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
bat files contain dir > a.txt and dir > b.txt so I can see if they actually executed.
It's somewhat frustrating, am I misunderstanding something?
Condition should be placed inside Custom element, not CustomAction. Also, you have no InstallFiles action during uninstalling. Use RemoveFiles instead.
<CustomAction Id="AAction" Directory="INSTALLFOLDER" Execute="deferred"
Impersonate="no" Return="check" ExeCommand="cmd.exe /c "a.bat"" />
<CustomAction Id="BAction" Directory="INSTALLFOLDER" Execute="deferred"
Impersonate="no" Return="check" ExeCommand="cmd.exe /c "b.bat"" />
<InstallExecuteSequence>
<Custom Action="AAction" After="InstallFiles">NOT Installed</Custom>
<Custom Action="BAction" Before="RemoveFiles">Installed</Custom>
</InstallExecuteSequence>
We've been using Wix to create our website msi for awhile and it install fine.
Issue (Little annoyance) -
If I install my msi, it will show up in add/remove programs but if Person B goes on the server, my msi entry will not show up for them in Add/Remove programs.
I'm assuming it's a property to set in the wix product.wxs page but google hasn't been friendly to me in that regard.
I wasn't sure if it was a win2k3 issue only but we just did a test on a win2k8R2 and the same issue occured.
Here's my product.wxs file
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<Product Id="*"
Name="!(loc.ProductName)"
Language="!(loc.LANG)"
Version="1.0.0.0"
Manufacturer="!(loc.CompanyName)"
UpgradeCode="1bf00ad4-a8a1-407b-8a07-0d3046cb7214">
<Package InstallerVersion="200" Compressed="yes" Manufacturer="!(loc.CompanyName)" Description="!(loc.Description)" />
<?include Settings.wxi ?>
<?include Conditions.wxi ?>
<?include WebSites.wxi ?>
<iis:WebAppPool Id="AppPool" Name="[APP_POOL_NAME]"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="IISMain" Name='WebSites'>
<Directory Id="WWWMain" Name='SigappsTest'
ComponentGuidGenerationSeed='5A8C3E4A-0AA2-488C-80EC-91921A1A36CC'>
<Directory Id='INSTALLLOCATION' Name='!(loc.VirtualDirectory)'>
<!-- The component to define the Virtual Directory.-->
<Component Id="WebVirtualDirComponent" Guid="8AD62CCC-3FD5-4121-8370-DFB466482E61">
<iis:WebVirtualDir Id="VDir" Alias="[VD]" Directory="INSTALLLOCATION" WebSite="SelectedWebSite">
<iis:WebApplication Id="MyWebAppApplication" WebAppPool="AppPool" Name="[VD]" />
</iis:WebVirtualDir>
<CreateFolder/>
<!-- Need to have to ensure created -->
</Component>
<Component Id="EnableASPNet4Extension" Permanent="yes" Guid="73FA6E54-2B0C-4AA7-A2A0-BDD432FECC62">
<CreateFolder/>
</Component>
<Component Id="PersistWebSiteValues" Guid="F249ADCB-B638-4E2B-9350-0421CEC5A803">
<RegistryKey Action="create" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\!(loc.VirtualDirectory)\Install">
<RegistryValue Name="WebSiteDescription" Type="string" Value="[WEBSITE_DESCRIPTION]"/>
<RegistryValue Name="WebSiteID" Type="string" Value="[WEBSITE_ID]"/>
<RegistryValue Name="WebSitePath" Type="string" Value="[WEBSITE_PATH]"/>
<RegistryValue Name="WebSiteVD" Type="string" Value="[VD]"/>
<RegistryValue Name="WebSiteAppPoolName" Type="string" Value="[APP_POOL_NAME]"/>
</RegistryKey>
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<iis:WebSite Id='SelectedWebSite' Description='[WEBSITE_DESCRIPTION]' Directory='INSTALLLOCATION' SiteId='[WEBSITE_ID]'>
<!-- This element has to be here or WiX does not compile. -->
<iis:WebAddress Id="AllUnassigned" Port="80"/>
</iis:WebSite>
<!-- Define our custom actions -->
<Binary Id="IISCA" SourceFile="$(var.IISCA.TargetDir)$(var.IISCA.TargetName).CA.dll" />
<CustomAction Id="GetIISWebSites" BinaryKey="IISCA" DllEntry="GetWebSites" Execute="immediate" Return="check" />
<CustomAction Id="UpdatePropsWithSelectedWebSite" BinaryKey="IISCA" DllEntry="UpdatePropsWithSelectedWebSite" Execute="immediate" Return="check" />
<CustomAction Id="UpdateWebConfigFile" BinaryKey="IISCA" DllEntry="UpdateWebConfig" Execute="immediate" Return="check" />
<CustomAction Id="RegisterScriptMaps" BinaryKey="IISCA" DllEntry="RegisterScriptMaps" Execute="immediate" Return="check" />
<CustomAction Id="SetApplicationRootDirectory" Directory="INSTALLLOCATION" Value="[WEBSITE_PATH]\[VD]" />
<!-- Install UI Sequence - allows us to schedule custom action -->
<InstallUISequence>
<Custom Action="GetIISWebSites" After="CostFinalize" Overridable="yes">NOT Installed</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="GetIISWebSites" After="CostFinalize" Overridable="yes">NOT Installed</Custom>
<Custom Action="UpdatePropsWithSelectedWebSite" After="GetIISWebSites">NOT Installed</Custom>
<Custom Action="SetApplicationRootDirectory" After="UpdatePropsWithSelectedWebSite">NOT Installed</Custom>
<Custom Action="UpdateWebConfigFile" After="InstallFinalize">NOT Installed</Custom>
<!--<Custom Action="UpdateWebAppMapping" After="InstallFinalize">NOT Installed</Custom>-->
<Custom Action="RegisterScriptMaps" After="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
<Feature Id="ProductFeature" Title="!(loc.ProductName)" Level="1">
<ComponentRef Id='WebVirtualDirComponent' />
<ComponentRef Id='EnableASPNet4Extension'/>
<!--<ComponentGroupRef Id="WebSecurity.Web_Project" />-->
<ComponentGroupRef Id="Product.Generated" />
<ComponentRef Id="PersistWebSiteValues" />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION"/>
<UIRef Id="WixUI_WebUI" />
</Product>
</Wix>
Set the Package/#InstallScope attribute to perMachine. The default in Windows Installer is to create per-user packages.
I have problem using wix to build msi installer which will install some bat file and run it. I found some example on the internet, but i was not able to make it work :/ here is my wix source file
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="44A8F987-6B89-422B-B41F-1364AE1EF0D5" Name="my_name" Language="1033" Version="1.11.5164" Manufacturer="company" UpgradeCode="BD8652F4-1C1A-4825-9799-7DFB499B9F12">
<Package Description="Test file in a Product" Comments="Simple test" InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Name="my_folder" Id="MY_FOLDER">
<Component Id="CONFIGURE.BAT" DiskId="1" Guid="041ED78B-3D42-4EBD-8DAE-29D94DEFFC20">
<File KeyPath="yes" Id="file_configure.bat" Name="configure.bat" Source="C:\Documents and Settings\root\Desktop\some_path\configure.bat" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="MainFeature" Title="Main Feature" Level="1">
<ComponentRef Id="CONFIGURE.BAT" />
</Feature>
<UI />
<UIRef Id="WixUI_Minimal" />
<CustomAction Id="BatchCmd" Property="BatchRun" Value=""[#file_configure.bat]"" Execute="immediate">
</CustomAction>
<CustomAction Id="BatchRun" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="yes">
</CustomAction>
<InstallExecuteSequence>
<Custom Action="BatchCmd" Before="BatchRun">NOT Installed</Custom>
<Custom Action="BatchRun" After="InstallFiles">NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
</Wix>
Configure.bat file is installed correctly, but it won't run during install. Plz help
I have to create an installation package using Wix. If an admin user is installing the package, it should install into %programfiles%/[applicationName], if the user is an non-admin user then it should install into its local profile folder( LocalAppDataFolder).
How it is possible?
I wrote this for ClickThrough a long time ago. Solution from that looks a lot like this (You provide a Property called "ApplicationFolderName"):
<Property Id="A" Secure="yes" />
<DirectoryRef Id="TARGETDIR">
<Directory Id="ApplicationFolder" Name="App" />
</DirectoryRef>
<Condition Message="Must specify TARGETDIR property when doing an administrative install.">Installed OR (ACTION="ADMIN" AND TARGETDIR<>"")</Condition>
<CustomAction Id="TARGETDIRtoA" Property="A" Value="[TARGETDIR]" Execute="firstSequence" />
<CustomAction Id="SpecifiedA" Property="ApplicationFolder" Value="[A]" Execute="immediate" />
<CustomAction Id="PerMachineInstall" Property="ApplicationFolder" Value="[ProgramFilesFolder]\[ApplicationFolderName]" Execute="immediate" />
<CustomAction Id="PerUserInstall" Property="ApplicationFolder" Value="[LocalAppDataFolder]\Apps\[ApplicationFolderName]" Execute="immediate" />
<InstallUISequence>
<Custom Action="SpecifiedA" Before="LaunchConditions">NOT Installed</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="PerMachineInstall" Before="CostFinalize">NOT Installed AND ACTION="INSTALL" AND A="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
<Custom Action="PerUserInstall" Before="CostFinalize">NOT Installed AND ACTION="INSTALL" AND A="" AND (ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged))</Custom>
</InstallExecuteSequence>
Overriding ProgramFilesFolder property as following should work:
<SetProperty Id="ProgramFilesFolder" Value="[AppDataFolder]" Before="CostFinalize"><![CDATA[ NOT Privileged]]></SetProperty>
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="INSTALLDIR" Name="My Folder">
...
</Directory>
</Directory>
Set property ALLUSERS to 2. See also Single Package Authoring.