WIX Feature for Windows

I need to check if some Windows features are enabled in order to install my software.

I can check or install it using the dis command line tool.

I am creating a custom action for this, but is there a way to do this in "WIX native"?

<Property Id="dism" Value="dism.exe" /> <CustomAction Id="InstallMSMQContainer" Property="dism" ExeCommand=" /online /enable-feature /featurename:MSMQ-Container /featurename:MSMQ-Server /featurename:MSMQ-ADIntegration" Return="check" Impersonate="yes" Execute="oncePerProcess"/> <InstallUISequence> <Custom Action="InstallMSMQContainer" After="CostFinalize" Overridable="yes">NOT Installed</Custom> </InstallUISequence> 

The problem is that the command launches the command line, which is very ugly for the end user. How can I do it better? I do not know if I need a bootstraper for this (e.g. installing the .NET Framework).

Is there any extension to manage these things?

Now I am using WIX 3.7.

+4
source share
3 answers

David Gardiner's answer hinted at the right decision in my case. Creating your own custom action is not required. Here's how to do it for a 64-bit installation of Windows:

First determine if MSMQ is installed:

 <Property Id="MSMQINSTALLED"> <RegistrySearch Id="MSMQVersion" Root="HKLM" Key="SOFTWARE\Microsoft\MSMQ\Parameters" Type="raw" Name="CurrentBuild" /> </Property> 

Announce your custom actions. You need two. One to set the properties of the path to the mind, and the other to execute it:

 <CustomAction Id="InstallMsmq_Set" Property="InstallMsmq" Value="&quot;[System64Folder]dism.exe&quot; /online /enable-feature /featurename:msmq-server /all" Execute="immediate"/> <CustomAction Id="InstallMsmq" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="deferred" Return="check"/> 

Finally, specify user actions in the installation sequence:

 <InstallExecuteSequence> <Custom Action="InstallMsmq_Set" After="CostFinalize"/> <Custom Action="InstallMsmq" After="InstallInitialize">NOT REMOVE AND NOT MSMQINSTALLED</Custom> </InstallExecuteSequence> 

Since this may take a little time, I added the following to update the installer status text:

 <UI> <ProgressText Action="InstallMsmq">Installing MSMQ</ProgressText> </UI> 

You can also specify the rollback action if you want to uninstall MSMQ if the installation fails.

+6
source
+2
source

How do I do this by creating a custom DTF action that calls the dism.exe process. You get the same result, and no command line is started.

 [CustomAction] public static ActionResult RunDism(Session session) { session.Log("Begin RunDism"); string arguments = session["CustomActionData"]; try { ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "dism.exe"; session.Log("DEBUG: Trying to run {0}", info.FileName); info.Arguments = arguments; session.Log("DEBUG: Passing the following parameters: {0}", info.Arguments); info.UseShellExecute = false; info.RedirectStandardOutput = true; info.CreateNoWindow = true; Process deployProcess = new Process(); deployProcess.StartInfo = info; deployProcess.Start(); StreamReader outputReader = deployProcess.StandardOutput; deployProcess.WaitForExit(); if (deployProcess.HasExited) { string output = outputReader.ReadToEnd(); session.Log(output); } if (deployProcess.ExitCode != 0) { session.Log("ERROR: Exit code is {0}", deployProcess.ExitCode); return ActionResult.Failure; } } catch (Exception ex) { session.Log("ERROR: An error occurred when trying to start the process."); session.Log(ex.ToString()); return ActionResult.Failure; } return ActionResult.Success; } 

DISM parameters are set using custom action data.

0
source

All Articles