19

How can I execute a command line from within a WiX script?

I want to dynamically generate a command line string and have it executed. I'm not installing a file related to this.

Using version 3.0.5419.

Todd Ropog
  • 1,133
  • 1
  • 14
  • 23

1 Answers1

29

What you probably want is something like this (observing quotes where necessary in the command):

<CustomAction Id='ExecNotepad' Directory='INSTALLDIR' Execute='immediate' 

ExeCommand='[SystemFolder]notepad.exe &quot;[SOMEFILE]&quot;' Return='ignore'/>

The ExeCommand is where you want to put your command. Here I have notepad launching with a file. Some of the attributes will be different, depending on what your command does - particularly the Execute and Impersonate parameters. It would also be helpful to know what version of WiX you were using (the code above is v2).

Xenon
  • 3,174
  • 18
  • 37
JohnL
  • 3,922
  • 3
  • 22
  • 22
  • 5
    Here's the page for the CustomAction element for v2: http://wix.sourceforge.net/manual-wix2/wix_xsd_customaction.htm and v3: http://wix.sourceforge.net/manual-wix3/wix_xsd_customaction.htm Hope that helps – JohnL Feb 22 '10 at 20:09
  • I check the documentation of the V3, but I could not find what would be different with your example, did I miss something? – J4N Sep 27 '17 at 09:38
  • 1
    Edit: Ok, now I understand. There probably wouldn't be a difference in this sample, I just wanted to point to both versions of the documentation because some related stuff is different BTW, here is the WiX v3 documentation on the new site: https://www.firegiant.com/wix/tutorial/events-and-actions/extra-actions/ Note that this is not how I actually do this nowadays, because I want more control over how errors are handled. I have a WiX extension which creates entries in a custom table, and a custom action (part of the same extension) which processes the entries. – JohnL Sep 28 '17 at 09:14