4

We have a desktop application installed through a windows installer (msi), and we want to add a custom action that relaunches the .exe when we have pass LAUNCH_APP=1 to the cmd.

So I have a vbs script that launch a bat file that launch install the msi (major upgrade):

vbs script:

Set WshShell = CreateObject("WScript.Shell")
Const TemporaryFolder = 2
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim tempFolder: tempFolder = fso.GetSpecialFolder(TemporaryFolder)
WshShell.Run chr(34) & WScript.Arguments(0) & chr(34) & chr(32) & chr(34) & tempFolder & "\Lifen\update\LifenInstaller.msi" & chr(34) & chr(32) & chr(34) & WScript.Arguments(1) & chr(34), 0, True
Set WshShell = Nothing

bat script:

@echo off 

call :start >%APPDATA%\Lifen\batMsiLog.log

:start
wmic process where "name='Lifen.exe'" delete
start /wait msiexec /i %1 /qn /norestart /log %APPDATA%\Lifen\msilog.log LAUNCH_APP=1

And in my wix installer (wix version 3.1.0) has this custom action:

<Property Id="WixQuietExecCmdLine" Value='"[INSTALLFOLDER]\Lifen.exe"'/>
<CustomAction Id="QtExecRestartApp" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="immediate" Return="check"/>
<InstallExecuteSequence>
  <Custom Action="QtExecRestartApp" After="InstallFinalize">LAUNCHAPP = 1</Custom>
</InstallExecuteSequence>

I don't know how to add an argument (like —new-version) to my custom action to relaunch my exe.

In the end, I would like to run the command:

Lifen.exe —new-version

I tried various ways to write it:

  • '"[INSTALLFOLDER]\Lifen.exe --new-version=x.x.x"'
  • '"[INSTALLFOLDER]\Lifen.exe" "--new-version=x.x.x"'

or also after reading this stackoverflow : How to add arguments to the custom action exe in Wix?

  • '"&quot;[#"[INSTALLFOLDER]\Lifen.exe"]"&quot; "--new-version"'
  • '"&quot;[#"[INSTALLFOLDER]\Lifen.exe"]"&quot; "--new-version"'

Does anyone have an idea ?

Thanks in advance

zett42
  • 25,437
  • 3
  • 35
  • 72

1 Answers1

2

Basic Syntax

<Property Id="WixQuietExecCmdLine" Value='"[INSTALLFOLDER]Lifen.exe" --new-version'/> 
  • You always need to quote paths, because they may contain spaces.
  • You don't need a backslash after folder properties like [INSTALLFOLDER], because the MSI runtime makes sure that the values of all installation folder properties end with backslash.
  • Same for the arguments, you need to quote if they may contain spaces. If you have a constant argument like --new-version where you know for sure that there are no spaces, you don't need to quote. For arguments that contain property references, it's safer to always quote. E. g.:

    <Property Id="WixQuietExecCmdLine" Value='"[INSTALLFOLDER]Lifen.exe" "--new-version=[NEWVERSION]"'/> 
    

If you are in doubt, have a look into the verbose log to see if the actual value of WixQuietExecCmdLine is what you expect. Activate verbose logging by calling msiexec -l*v logfile.txt <OtherParameters>.

64-Bit Executables

To run 64-bit executables, use the WixQuietExec64 custom action and WixQuietExec64CmdLine property instead.

zett42
  • 25,437
  • 3
  • 35
  • 72
  • Thanks a lot for your reply. I tried with verbose logs and as you specified but I can see in the logs that : – Valentine Langer Mar 05 '19 at 18:10
  • Property(S): WixQuietExecCmdLine = "[INSTALLFOLDER]Lifen.exe" --new-version Property(S): WixShellExecTarget = "[INSTALLFOLDER]\Lifen.exe" – Valentine Langer Mar 05 '19 at 18:10
  • The 1st line is the specific custom action with LAUNCH_APP. The 2nd line is another custom action that launches the app after the installation. It is detail and I read what you said about \ and writing [INSTALLFOLDER]Lifen.exe but it does not change anything.. Do you have any other idea why it is not working ? – Valentine Langer Mar 05 '19 at 18:11
  • @ValentineLanger Oh well, how I didn't see that. When the value of a property contains references to other properties, it can't be set through ``. This doesn't resolve the property references, as can be seen from your log. You need to use `` instead. See example at the [documentation page](http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html). Everything else I wrote still holds true. – zett42 Mar 06 '19 at 08:26