How to call a command line program in WiX

I want to call the OpenOffice command-line program on WiX. To do this, I created a custom action, as shown below:

<CustomAction Id="ca_RunOpenOfficeProgram" Return="check" Directory="TARGETDIR" ExeCommand="cmd.exe /K &quot;C:\OpenOffice.org3\program\unopgk.com list --shared&quot;" /> 

The user action is launched in the execution sequence:

 <InstallExecuteSequence> <Custom Action="ca_RunOpenOfficeProgram" Before="InstallFinalize" /> </InstallExecuteSequence> 

When I run the resulting MSI file, I get the following error message on the command line:

 Invalid command 'C:\OpenOffice.org3\program\unopkg.com' could not be found. 

Well, of course, the command is available, and I can run it from the command line. But that just doesn't work if the command line is called by WiX. It is also noteworthy that the "list -shared" part is completely ignored.

Does anyone know what is going on here?

+6
source share
3 answers

Found a solution for my problem:

1) As written in my answer to Tom's post, I have a typo on the command line ... stupid.

2) Quotation marks regarding command line invocation were inappropriate (Tom's answer)

3) I found out that launching "unopkg.com" with the parameter "shared" is performed only when the command line is started with administrator rights. I thought the attribute "impersonated =" yes "" in my CustomAction would be enough, but that didn't help. I think I need to delve deeper into the WiX documentation regarding UAC.

Also thanks to Ralph. I have not tried solving it, but you can do it.

0
source

I would recommend using ShellExecute custom action from the WiX toolkit.

Here is a sample code:

 <Property Id="WixShellExecTarget" Value="[#myapplication.exe]" /> <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" /> 

Change the Value WixShellExecTarget property to cmd.exe /K &quot;C:\OpenOffice.org3\program\unopgk.com list --shared&quot; and it should work.

+5
source

Are you sure cmd.exe /K "C:\OpenOffice.org3\program\unopgk.com list --shared" ? It looks like you have quotes in the wrong place.

And do you really want the console window to stay open ( /k )? Should the user enter additional commands before the installation is complete? Instead, you may need /c . See Help cmd /? .

But if only one command is required, why not just run the program directly?

 ExeCommand="&quot;C:\OpenOffice.org3\program\unopgk.com&quot; list --shared" 

Finally, if the above information is the only necessary command and it is assumed that C:\OpenOffice.org3\program\unopgk.com is a console application, a useless console window will open. This can be avoided by using the custom WiX QtExecCmdLine action .


If you run a program to collect information, and this is a console application, you can do:

 cmd /c &quot;C:\OpenOffice.org3\program\unopgk.com&quot; list --shared >path\out.txt 

and use another custom action to read the file and make a decision about it or show it to the user in the Windows Installer dialog box. This would be better than leaving the user a console window with a blinking prompt that they should exit.

+3
source

Source: https://habr.com/ru/post/949103/


All Articles