How can I pass an folder path to an custom action ExeCommand - wix

We have the following folder structure in our wix declaration:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="$(var.ProgramFilesFolder)">
<Directory Id="ManufacturerFolder" Name="$(var.Manufacturer)">
<Directory Id="APPLICATIONFOLDER" Name="$(var.AppFolderName)">
// further folders or files
</Directory>
</Directory>
</Directory>
</Directory>
Target: We want to delete the APPLICATIONFOLDER on an uninstall. RemoveFolderEx and RemoveFolder will not work for this task, so we need to use a CustomAction. The CustomAction:
<CustomAction Directory="ManufacturerFolder" ExeCommand='/c rmdir /S /Q "[APPLICATIONFOLDER]"' Id="RemoveAppFolder" Execute="deferred" Impersonate="no" Return="ignore"/>
This custom action deletes nothing. What is the correct declaration?

Why Don't you do it like this?
It must work on uninstall.
For example just place it in component where you have shortcut creation.
<RemoveFolder
Id="rem_folder"
Directory="APPLICATIONFOLDER"
On="uninstall"/>
<RemoveFile Id="rem_files"
On="uninstall"
Directory="APPLICATIONFOLDER"
Name="*.*"/>

Related

How to set Wix Property from UI which user can change during installation?

I have Wix Code which simply installs a txt file in the given location
The target location is enclosed in a Property THISONE
<Fragment>
<Property Id="THISONE" Value="C:\MyFolder"/>
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='APPLICATIONFOLDER' ComponentGuidGenerationSeed="{75266e3e-3781-47e3-ac29-46a2d90548f9}">
<Directory Id='MyFolder' Name='MyFolder'/>
</Directory>
</Directory>
<SetDirectory Id='APPLICATIONFOLDER' Value='[THISONE]' />
</Fragment>
<Fragment>
<Component Id="Component1" Directory="MyFolder" Win64="yes">
<File Id="FirstFile.txt"/>
</Component>
</Fragment>
I want a minimal UI with maybe just a textbox where I can edit the property value so that I can change the target installation file path.
How can I achieve that ?
Thanks in Advance
The WiXUIInstallDir may be what you want, as described in the WiX documentation.
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='APPLICATIONFOLDER' ComponentGuidGenerationSeed="{75266e3e-3781-47e3-ac29-46a2d90548f9}">
<Directory Id='MyFolder' Name='MyFolder'/>
</Directory>
</Directory>
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER" />
<UIRef Id="WixUI_InstallDir" />
You must set the value of the property WIXUI_INSTALLDIR to the value of the ID of the directory you want the user to be able to specify the location of, as shown above. This is then passed to the WixUI_InstallDir dialog. Note that the directory ID must all be uppercase.
If you're using Visual Studio, you'll need to add a reference to WixUIExtension to your WiX project. See here for more details.

WiX nesting child directories under installation directory

I am creating a WiX installer and allow the user to change the installation directory INSTALL_FOLDER. If the user changes the installation directory, say to D:\Here then adding a component file to AAX_BIN_FOLDER still results in the file being added to C:\Program Files\Manufacturer\Product\Test AAX Plugin\Context\x64\Test.aaxplugin rather than D:\Here\Test AAX Plugin\Context\x64\Test.aaxplugin.
What am I doing wrong in the following XML?
<Feature Id="AAX" Title="AAX" Level="1">
<ComponentGroupRef Id="group.AAX" />
</Feature>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.Program_Files)">
<Directory Id="INSTALL_FOLDER_MANUFACTURER" Name="$(var.Manufacturer)">
<Directory Id="INSTALL_FOLDER" Name="$(var.Short_Name)">
<Directory Id="INSTALL_AAX_PLUGIN_FOLDER" Name="$(var.Short_Name) AAX Plugin">
<Directory Id="INSTALL_AAX_CONTENT" Name="Content">
<Directory Id="INSTALL_AAX_BIN_FOLDER" Name="$(var.AAX_Architecure)" />
<Directory Id="INSTALL_AAX_RESOURCES_FOLDER" Name="Resources" />
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
<ComponentGroup Id="group.AAX">
<Component Id='component.AAX' Guid='$(var.Component_Aax_Guid)' Transitive="yes" Directory="AAX_BIN_FOLDER">
<File Id="file.AAX" Source='..\..\build_release$(var.Architecture_Number)\Test.aaxplugin' Name="Test.aaxplugin" Vital='yes' KeyPath='yes' />
</Component>
</ComponentGroup>
</Fragment>
The problem is the upper casing of the folder IDs below INSTALL_FOLDER. Changing these to have some lower case characters fixed the issue. This seems to be due to upper case only IDs being treated differently.

Calling custom exe in ExitDialog

I’m beginning with WiX and I have some trouble to customize ExitDIalog.
At first what I want:
I want to create a setup for my application
After setup I want to propose 2 choices :
Launch application (application.exe newly installed)
Launch an optional setup (my application require to install some drive depending of user’s camera)
The optional setup is a .exe. It should be placed next to setup.msi but no copied in my application folder.
I created directories :
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="$(var.compagny)"/>
</Directory>
<Directory Id="DesktopFolder" SourceName="Desktop"/>
<Directory Id="ProgramFilesFolder">
<Directory Id="COMPAGNYFOLDER" Name="$(var.compagny)">
<Directory Id="INSTALLFOLDER" Name="$(var.product)">
<Directory Id="fr" Name="fr"/>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
How can I add a reference to my .exe ? I did :
<Component Id="ProductComponent" Guid="{2C26B191-6654-4405-8E78-F8B6EFEDC9FC}" Directory="INSTALLFOLDER">
<File Id="uEye64_47100_WHQLexe" Source="./Resources/uEye64_47100_WHQL.exe" KeyPath="yes" Checksum="yes" Compressed="no" Vital="no"/>
</Component>
But the uEye64_47100_WHQL.exe file is copied in INSTALLFOLDER (I don't want) and the setup mix the path with [application]/bin/Release (don't know with). In the log file there is :
Failed to open the file:C:\dev\MyApplication\main\SetupProject\bin\Release\MyCompagny\MyProduct\uEye64_47100_WHQL.exe for computing its hash. Error:3
And I call the .exe like this (this file require elevated privileges)
<!-- Set checkbox for launch install uEye -->
<Property Id="WIXUI_EXITDIALOGUEYECHECKBOXTEXT" Value="Launch install uEye"/>
<CustomAction Id="SetExecUEye" FileKey="uEye64_47100_WHQLexe" ExeCommand="" Return="asyncNoWait" Impersonate="no" Execute="deferred"/>
<UI>
<UIRef Id="WixUI_Custom"/>
<Publish Dialog="MyExitDialog"
Control="Finish"
Event="DoAction"
Value="SetExecUEye">WIXUI_EXITDIALOGUEYECHECKBOX = 1 and NOT Installed</Publish>
</UI>
How should I define my uEye64_47100_WHQL.exe to be called after setup but no copied in INSTALLFOLDER ?
If you don't want to copy file to install location, just run it, you can include it as Binary source instead of component. This way, it is packed in installer, but is not deployed on installation (probably to some temp folder only).
<Binary Id="uEye64_47100_WHQLexe" SourceFile="./Resources/uEye64_47100_WHQL.exe" />
<CustomAction Id="InstalluEye64exe" BinaryKey="uEye64_47100_WHQLexe" ExeCommand="" Execute="deferred" Return="ignore" Impersonate="no"/>

WIX: how to call custom action exe with parameters

I want to call a .exe under PCMINSTALLDIR with parameters so I can use the parameters passed in the .exe. When I run the installer, it said my installer has a problem. Can anyone tell me what's wrong with my code? And how to debug it? Thanks.
WiX file:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
<Directory Id="CompanyDir" Name="ABC">
<Directory Id="PCMINSTALLDIR" Name="ClientMonitor">
<Directory Id="STDSCIPTSDIR" Name="standard_scripts">
</Directory>
<Directory Id="CSTMSCIPTSDIR" Name="custom_scripts">
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
.....
<CustomAction Id="ChangeConfigExe" Directory="PCMINSTALLDIR" ExeCommand ='PcmConfigExe.exe Hello' Execute="deferred" Impersonate="no" Return="check" />
<InstallExecuteSequence>
<Custom Action="ChangeConfigExe" Before="InstallFinalize" />
</InstallExecuteSequence>

How to create a directory in Wix on D:

Using WiX 3.7, I have figured out how to create a folder in the root. This
<Directory Id="ReceivedFilesDir" Name="ReceivedFiles">
<Component Id="ReceivedFilesComponent" Guid="84A264EF-2BC5-41e3-8124-2CA10C2805DB">
<CreateFolder Directory="ReceivedFilesDir">
<Permission User="Administrators" GenericAll="yes" />
</CreateFolder>
</Component>
</Directory>
creates a folder C:\ReceivedFiles
I want it to be at D:\ReceivedFiles instead.
How do I achieve that?
I have played around with the DiskId attribute, but it did not seem to do anything.
Also, I don't want to change the whole installation folder, the ordinary part of the installation will still be below C:\Program Files (x86). I just want to create additional folders on D:.
Here's the solution we used for basically the same need:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="CROOT" Name="root">
<Directory Id="MY_CROOT" Name="PLACE_HOLDER">
<!-- Define C directory -->
</Directory>
</Directory>
<Directory Id="TROOT" Name="root">
<Directory Id="MY_TROOT" Name="PLACE_HOLDER">
<!-- Define T directory -->
</Directory>
</Directory>
</Directory>
<CustomAction Id="SetCRootDirectory" Property="CROOT" Value="C:\" />
<CustomAction Id="SetTRootDirectory" Property="TROOT" Value="T:\" />
<InstallExecuteSequence>
<Custom Action="SetCRootDirectory" Before="AppSearch" />
<Custom Action="SetTRootDirectory" Before="AppSearch" />
</InstallExecuteSequence>
You could add this to a UI sequence if your install takes advantage of that. You may need to set the Custom Action Before values to some other value given how all the rest of your sequences are defined. Hope this is useful.