Search code examples
xmlvbscriptwixwix3.9

executing VBscript after installation on target machine


I am trying to run an executable VBscript (.EXE) after all the files are placed on the target machine. the installer that is being used is made in Visual Studio 2013 with the WIX toolset. I tried a couple of examples from different sources like technet and this website. However none could help me since a lot of those articles/post are from around 2008 and don't seem to apply anymore.

currently I am using this piece of code to try to archieve my goal:

     <Fragment>
    <CustomAction
      Id="RunInstallScript"
      Directory="INSTALLFOLDER"
      ExeCommand="[INSTALLFOLDER]Installation script.exe"
      Execute="commit"
      Return="ignore"
    />
    <InstallExecuteSequence>
    <Custom Action="RunInstallScript" Before="InstallFinalize" />
  </InstallExecuteSequence>
  </Fragment>

Even though the compiler doesn't see any errors and compiles just fine the code isn't working. The file that needs to be executed is placed in the installation folder, so the file is present. The only thing left is to execute it once during installation and/or De-installation.

I have searched for information for a long time in order to figure it out, bud i just can't get it working the way I would like it. if this problem is solved I will finaly have a fully functioning installer that I can deploy to streamline the setup of control panels.

all help and suggestions are welcome.

thanks in advance,


Solution

  • I figured out what the problem was. it seems that the declaration and calling of the custom action need to be in the same fragment as the add file function. so it will look something like this:

        <Fragment>
    
        <ComponentGroup Id="script" Directory="INSTALLFOLDER">
          <Component Id="InstallationScript" Guid="{AFA49EED-4F2C-42B4-B7EC-D3B7896C970C}">
            <File Id="InstallationScript" KeyPath="yes" Source="C:\Users\fjansen\Documents\Visual Studio 2013\Projects\Wix test\Installation script\bin\Debug\InstallationScript.exe" />
          </Component>
        </ComponentGroup>
    
        <CustomAction
          Id="InstallScript"
          Directory="INSTALLFOLDER"
          ExeCommand="[INSTALLFOLDER]InstallationScript.exe"
          Execute="commit"
          Return="check">
        </CustomAction>
        <InstallExecuteSequence>
          <Custom Action="InstallScript" Before="InstallFinalize" />
        </InstallExecuteSequence>
    
      </Fragment>
    

    it was just a small error in the end bud it was not easy to find what the problem was. i hope this example will help people solve this same problem and save them a lot of time figuring out what the problem is.