1

I am struggling to run a VBS script through WIX which in turn runs a bat file. I tried couple of scenarios but nothing is working. Can some one help me to identify the mistake I am doing

Code

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
      <Product Id="*" 
               Name="My Software"
               Language="1033"
               Manufacturer="My Company"
               Version="1.0.0.0" 
               UpgradeCode="8c7d85db-b0d1-4a9a-85ea-130836aeef67">
        
        <Package InstallerVersion="200" 
                   Compressed="yes" 
                   InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes" />

        <Property Id="QtExec64CmdLine" Value="C:\SampleWix\myBat.bat"/>
        <CustomAction Id="SilentLaunch" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="check" />

        <InstallExecuteSequence>
          <Custom Action="SilentLaunch" Sequence="6524">1</Custom>
        </InstallExecuteSequence>

        <Feature Id="ProductFeature"    
                   Title="The main feature" 
                   Level="1">
          <ComponentGroupRef Id="ProductComponents" />
        </Feature>
      </Product>

      <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" 
                           Name="My Software" />
          </Directory>
        </Directory>
      </Fragment>

      <Fragment>
        <ComponentGroup Id="ProductComponents" 
                          Directory="INSTALLFOLDER">
          <Component Id="cmpMyTextFileTXT" 
                        Guid="{A4540658-09B6-46DA-8880-0B1962E06642}">
            <File Source="MyTextFile.txt" />
          </Component>
        </ComponentGroup>
      </Fragment>
    </Wix>

Bat file

echo "helloworld" > C:\SampleWix\Sijith.txt

Other Scenarios I tried is

    //Scenario 1 
    <!-- WixQuietExecCmdLine specify the cmd to be executed -->
    <Property Id="WixQuietExecCmdLine" Value=""/>

    <!-- From WiX v3.10, use WixQuietExec -->
    <CustomAction Id="MyAppTaskKill" Property="WixQuietExecCmdLine" Value="C:\SampleWix\myBat.bat"     BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="immediate" Return="ignore"/>

    <!-- trigger the custom action -->
    <InstallExecuteSequence>
        <Custom Action='MyAppTaskKill' Before='InstallValidate'></Custom>  
    </InstallExecuteSequence>
    
    //Scenario 2 
    <Binary Id='KillThatProcessBinary' SourceFile='C:\SampleWix\initate.vbs' />
     <CustomAction Id="KillThatProcessAction" VBScriptCall='' Execute="commit" BinaryKey='KillThatProcessBinary' Return="check"/>

    <InstallExecuteSequence>
        <Custom Action='KillThatProcessAction' Sequence="6524"> 1 </Custom>
    </InstallExecuteSequence>
    
    //Scenario 3 
    <Property Id="QtExecCmdLine" Value='"[System64Folder]cmd.exe" /F /IM initate.vbs'/>
    <CustomAction Id='SetTASKKILLFILEPATH64' Property='QtExecCmdLine' Value='[System64Folder]\cmd.exe' Return='check' />
    
    <InstallExecuteSequence>
      <Custom Action='SetTASKKILLFILEPATH64' After='AppSearch'>VersionNT64</Custom>
    </InstallExecuteSequence>

Running VBS script directly working fine and it calls bat correctly

Sijith
  • 3,740
  • 17
  • 61
  • 101
  • This construct must not be used - it is too error prone and clunky. Suggest you write [**a proper C++ custom action**](https://stackoverflow.com/a/54929785/129130) to invoke the setup.exe. [**Here is a step-by-step for managed code (C#)**](https://stackoverflow.com/a/60384739/129130). Managed code usually works well, but there is nothing like real C++ code for reliability and debug-ability - if you can handle the complexity and line-noise. – Stein Åsmul Aug 10 '20 at 11:43

0 Answers0