WIX: how to call custom action exe with parameters - wix

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>

Related

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.

WIX won't execute command

I have a WIX installer and I need to run two commands:
net localgroup administrators reviewer /add
and
appcmd.exe set config /section:applicationPools /[name='Reviewer'].processModel.identityType:SpecificUser /[name='Reviewer'].processModel.userName:reviewer /[name='Reviewer'].processModel.password:reviewer
the second command is quite complex and involved square brackets and single quotes
First command must run from C:\Program files\mycompany\myfolder, the second one from C:\windows\system32\inetsrv
Here my two WIX custom actions:
<CustomAction Id="AssignUserToAdminGroup" Directory="INSTALLFOLDER" Execute="deferred" Impersonate="no"
ExeCommand="net localgroup administrators reviewer /add"
Return="check"/>
<CustomAction Id="AssignUserToIISapp" Directory="IISFOLDER" Execute="deferred" Impersonate="no"
ExeCommand="appcmd.exe"
Return="check"/>
As you may have noticed I removed a lot from the second command just to make sure I don't have to deal with square brackets and single quotes (it's just a test)
Here the fragment which specifies the directories where such commands should be launched from (INSTALLFOLDER and IISFOLDER)
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="CommonAppDataFolder">
<Directory Id="Company" Name="mycompany">
<Directory Id="INSTALLFOLDER" Name="myfolder" />
</Directory>
</Directory>
<Directory Id="System64Folder" >
<Directory Id="IISFOLDER" Name="inetsrv" />
</Directory>
</Directory>
</Fragment>
This code compiles fine but I get an error while installing, the appcmd.exe could not be executed. What's causing the problem?

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"/>

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

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="*.*"/>

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.