Windows Installer XML(WIX) Help: Not able to execute shell command through exeCommand - wix

Following is my code. I need to install the .inf and .cer files after execution of the MSI file. I have tried referring to various wix resources but couldn't find anything. I am testing the installer on a virtual machine but it doesn't seem to work. I am new to wix and need help regarding this by going through the code and pointing out my mistakes.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="Cal" Language="1033" Version="1.0.0.0" Manufacturer="Cal" UpgradeCode="my-code">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<Feature Id="ProductFeature" Title="Cal" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<!--<CustomActionRef Id="InstallAction1" />-->
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Cal" />
<Directory Id="SilInst" Name="BackInst">
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="P2">
<File Source="C1.sys" />
</Component>
<Component Id="P6">
<File Source="C1.inf" />
</Component>
<Component Id="P7">
<File Source="C1.cer" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<CustomAction Id='InstallAction1' Directory='INSTALLFOLDER' ExeCommand='RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 C1.inf' Execute='deferred'
Return='check'/>
<CustomAction Id='InstallAction2' Directory='INSTALLFOLDER' ExeCommand='certutil -addstore C1.cer -s -r localMachine trustedpublisher' Execute='deferred'
Return='check'/>
<InstallExecuteSequence>
<Custom Action="InstallAction2" After='InstallFiles'/>
<Custom Action="InstallAction1" After='InstallAction2'/>
</InstallExecuteSequence>
</Fragment>
</Wix>

To troubleshoot, create an installation log, then search for the custom action id.
Installing driver and certificate on machine typically requires elevated permissions. Therefore use Impersonate="no" for your custom actions. See How to run a Custom Action inside an MSI created in WiX with elevated privileges?

Related

WIX CustomAction conditions

I created a simple WIX project with a "Hello world" custom action and checked how it works. I intended the custom action to be executed only on the first install, but it executed on every major update(where both the product code and its version change). I found in the log that the custom action condition is checked after uninstall - when the Installed variable is false again.
How do I execute a custom action on the first install only and not on major updates, using the WIX toolset?
Is there a way without manual use of the registry?
<Product Id="52D5F5ED0C3F453CA70E280ECD7D7400"
Name="TestWiXSetup"
Language="1033"
Version="1.0.2.0"
Manufacturer="Some RnD"
UpgradeCode="12777105-8bc1-47b5-8b36-2705ef02cb79">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab='yes' />
<Feature Id="ProductFeature" Title="TestWiXSetup" Level="1">
<ComponentRef Id="Component" />
</Feature>
<Binary Id="HW" SourceFile="HW.exe" />
<CustomAction Id="HWA" BinaryKey="HW" ExeCommand="" Execute='deferred'/>
<InstallExecuteSequence>
<Custom Action='HWA' After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="TestWiXSetup">
<Component Id="Component">
<File Source="ToDeploy.txt"/>
</Component>
</Directory>
</Directory>
</Directory>
</Fragment>

WiX quiet execution of .cmd file

When using WixQuietExec the command line file I am trying to launch does not appear to run during installation.
My reason for doing this is that the installer I am building necessitates running a number of .exe/.bat files in a particular sequence to build correctly.
.wxs file
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="immediateExecution" Language="1033" Version="1.0.0.0" Manufacturer="test" UpgradeCode="8b6b82f7-ecbb-426d-bd9a-6fb7548ac349">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="immediateExecution" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="immediateExecution" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
</ComponentGroup>
<Property Id="WixQuietExecCmdLine" Value="blankfile.cmd"/>
<CustomAction Id="QtExecExample" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="immediate" Return="check"/>
<InstallExecuteSequence>
<Custom Action="QtExecExample" Sequence="1"/>
</InstallExecuteSequence>
</Fragment>
</Wix>
blankfile.cmd
cd C:\Users\ljn\Desktop
copy NUL EMptyFile.txt
This is obviously a test case to check the functionality can be achieved in WiX. From the documentation it seems this should be easily achievable, yet the example here is not producing the desired result. Is there something wrong with the .wxs file? Please bear in mind that the utils reference has been added correctly in VS.

Wix how to hide feature options (no subfeatures)

There is a similar question
Edit context menu (selectiontree) in customize dialog?
but the link in the accepted answer states:
"You cannot remove Entire feature will be installed on local hard drive from the options. It is displayed only when there are subfeatures and enables installation of the subfeatures as well as the feature itself as opposed from Will be installed on local hard drive which installs only the selected features and does not affect subfeatures."
However, I have no subfeatures. How to remove the Entire feature... option?
Here's the code below:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="WixTestFeatureTree" Language="1033" Version="1.0.0.0" Manufacturer="TestManufacturer" UpgradeCode="bb04a635-6251-4fd5-8d2f-182d3441dc0a">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />
<Feature Id="ExeFeature" Title="The EXE file" Level="1">
<Component Id="TheApp" Guid="*" Directory="INSTALLFOLDER">
<File Id="TestExe" Source="Test.exe" Vital="yes"></File>
</Component>
</Feature>
<Feature Id="PdfFeature" Title="The PDF file" Level="1">
<Component Id="ThePDF" Guid="*" Directory="INSTALLFOLDER">
<File Id="TestPDF" Source="Test.pdf" Vital="yes"></File>
</Component>
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="WixTestFeatureTree" />
</Directory>
</Directory>
</Fragment>
</Wix>
It looks Windows Installer always displays Entire feature will be installed on local hard drive item even if there are no subfeatures. At least this item was present in all the cases that I tested where there were no visible subfeatures. It could also depend on the version of Windows Installer, I tested in Windows 7 with all the latest updates.
I've always thought Windows Installer doesn't display Entire feature will be installed on local hard drive item for a feature which has no subfeatures. Latest tests proved I was wrong.
You need to add the UI type in order to have a different UI in the installer.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="WixTestFeatureTree" Language="1033" Version="1.0.0.0" Manufacturer="TestManufacturer" UpgradeCode="bb04a635-6251-4fd5-8d2f-182d3441dc0a">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<UI Id="MyWixUI_FeatureTree">
<UIRef Id="WixUI_FeatureTree" />
</UI>
<UIRef Id="WixUI_ErrorProgressText" />
<Feature Id="ExeFeature" Title="The EXE file" Level="1">
<Component Id="TheApp" Guid="*" Directory="INSTALLFOLDER">
<File Id="TestExe" Source="Test.exe" Vital="yes"></File>
</Component>
</Feature>
<Feature Id="PdfFeature" Title="The PDF file" Level="1">
<Component Id="ThePDF" Guid="*" Directory="INSTALLFOLDER">
<File Id="TestPDF" Source="Test.pdf" Vital="yes"></File>
</Component>
</Feature>
<UIRef Id="WixUI_Mondo"></UIRef>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="WixTestFeatureTree" />
</Directory>
</Directory>
</Fragment>
</Wix>
add <UIRef Id="WixUI_Mondo"></UIRef> , also add reference to WixUIExtension.dll
each feature has **Level**attribute, level=1 meaning the feature will be installed, if you change the level for 1000 for example the user can pick in the custom dialog weather he wants to install this feature or not

CustomAction in Wix not executing

So I'm creating my first Wix project and I seem to be having a problem executing a custom action. I'm not sure that it's being included in the msi and I'm not quite sure what I'm doing wrong. The following is my Wix file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="ExactaDynamicManifest" Language="1033" Version="1.0.0.0" Manufacturer="Bastian Software Solutions" UpgradeCode="274ff2d9-e291-4706-a8db-ce80ccd91538">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="ExactaDynamicManifest" Level="1">
<ComponentGroupRef Id="ExactaDynamicManifest"/>
</Feature>
<Icon Id="exacta.ico" SourceFile="icons\exacta.ico"/>
<Property Id="ARPPRODUCTICON" Value="exacta.ico" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ExactaFolder" Name ="Exacta">
<Directory Id="INSTALLFOLDER" Name="ExactaExactaDynamicManifest" />
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<CustomAction Id="InstallService" FileKey="ExactaDynamicManifest.exe" ExeCommand="install"/>
<InstallExecuteSequence>
<Custom Action="InstallService" After="InstallFinalize"/>
</InstallExecuteSequence>
</Fragment>
</Wix>
The last fragment contains my custom action which what I hoped would do is the following on the command line after all files have been placed in the directory:
ExactaDynamicManifest.exe install
One thing to note is that exe is actually coming from a ComponentGroupRef defined above. Not sure if this is a problem or not but thought I'd mention it. Any help would be appreciated.
I finally got something that is working. My initial problem of the CustomAction not loading seemed to be due to it being in a different <fragment>. I consolidated all of the code into a single fragment and it seemed to run.
After battling with user permissions etc I finally ended up with this solution:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="ExactaDynamicManifest" Language="1033" Version="1.0.0.0" Manufacturer="Bastian Software Solutions" UpgradeCode="274ff2d9-e291-4706-a8db-ce80ccd91538">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="ExactaDynamicManifest" Level="1">
<ComponentGroupRef Id="ExactaDynamicManifest"/>
</Feature>
<Icon Id="exacta.ico" SourceFile="icons\exacta.ico"/>
<Property Id="ARPPRODUCTICON" Value="exacta.ico" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ExactaFolder" Name ="Exacta">
<Directory Id="INSTALLFOLDER" Name="ExactaExactaDynamicManifest" />
</Directory>
</Directory>
</Directory>
<CustomAction Id="RunTopShelfServiceInstall" Directory="INSTALLFOLDER" Execute="deferred" Return="ignore" Impersonate="no" ExeCommand="[INSTALLFOLDER]ExactaDynamicManifest.exe install"/>
<CustomAction Id="RunTopShelfServiceUninstall" Directory="INSTALLFOLDER" Execute="deferred" Return="ignore" Impersonate="no" ExeCommand="[INSTALLFOLDER]ExactaDynamicManifest.exe uninstall"/>
<InstallExecuteSequence>
<Custom Action="RunTopShelfServiceInstall" After="InstallFiles">
NOT Installed
</Custom>
<Custom Action="RunTopShelfServiceUninstall" After='InstallInitialize'>
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
</InstallExecuteSequence>
</Fragment>
</Wix>
Are you going to register a service using a custom action?
You also have to handle uninstall, repair actions.
It's much simpler to use standard MSI feature to install services:
http://wixtoolset.org/documentation/manual/v3/xsd/wix/serviceinstall.html
If you want to use custom actions for this purpose and UAC is enabled your service won't be installed due to permissions.
You have to use deferred and not impersonated custom action scheduled before InstallFinalize (after InstallFinalize custom actions can't be scheduled).

WiX build warning: The Media table has no entries

I'm trying to create a simple installer for a .net application in WiX. I installed Votive and am using the basic template wxs file it creates. When I compile it I get warning LGHT1076: ICE71: The Media table has no entries.
Also when I run the installer it starts and disappears during installation and there is no entry in the Add/Remove Programs app.
Here's the XML:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="26d654fe-af0f-4b48-8993-8e249597a130"
Name="Minefold"
Language="1033"
Version="0.0.0.1"
Manufacturer="Minefold"
UpgradeCode="6aad5a10-cbbe-472b-87fc-0813fb450836">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Minefold" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent">
<File Source="C:\code\Minefold\Minefold\bin\Debug\Minefold.exe" Id="Minefold.exe" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<Feature Id="Application" Title="Minefold" Level="1">
<ComponentRef Id="ProductComponent" />
</Feature>
</Fragment>
</Wix>
Add a Feature with a ComponentGroupRef to your Product. As written, nothing connects the Product with the content in the Fragments.