[wix-users] Custom Action - Call a Lua File

Russell Haley russ.haley at gmail.com
Mon Feb 5 22:51:34 PST 2018


Hi,

So I have added the checkbox item to the exit dialog and I can
successfully launch the installed lua.exe via WixShellExec, but I
can't run it with a script. I've tried creating a batch file and
launching it that way too, with no success.  What I want to do is
execute the following command, preferrably in a visible shell:

lua.exe ..\tools\fetch-luarocks.lua -install <path to folder> -bin
<path to installed bin> ...

Attempts so far (without the command line options):

<!-- THIS WORKS, BUT I WANT TO LAUNCH MY SCRIPT
  <Property Id="WixShellExecTarget" Value="[#lua.exe]"  />
  <CustomAction Id="LaunchApplication"
              BinaryKey="WixCA"
              DllEntry="WixShellExec"
              Impersonate="yes" />-->

<!--THIS FAILED WITH ?
  <CustomAction Id="LaunchApplication"
              FileKey="run_fetch.bat"
              ExeCommand=""
              Execute="immediate"
              Impersonate="yes"/>-->

    <!--THIS DIDN"T WORK AT ALL. Exit code 1
    <CustomAction Id="RunLua"
                  FileKey="lua.exe"
                  Win64="no"
                  ExeCommand="..\tools\fetch-luarocks.lua" />
    <InstallExecuteSequence>
      <Custom Action="RunLua" After="InstallFinalize" />
    </InstallExecuteSequence>-->

hmmmm....

Russ


On Sun, Feb 4, 2018 at 8:56 PM, Russell Haley <russ.haley at gmail.com> wrote:
> Holy crap, there's like real, *useful* help files in my wix
> installation. I'm gobsmacked. I can't remember the last time I didn't
> open a chm file and groan.
>
> Thanks!
> Russ
>
> On Wed, Jan 31, 2018 at 11:19 PM, Russell Haley <russ.haley at gmail.com> wrote:
>> Hello,
>>
>> TLDR;
>>
>> My custom action returns Exit code 1 in the debug logs. I don't know
>> how to pass the "relative installation path" in the CustomAction to
>> the script I want called. Here is the product.wxs files with the
>> custom action at the bottom. Any input would be grand.
>>
>> https://github.com/WinLua/WinLua-VisualStudio/blob/master/Visual%20Studio/WinLua-Installer/Product.wxs
>>
>> Full Content:
>>
>> I have an installer for Lua on Windows I'm now calling WinLua. It
>> works quite well so far. I would like to add the ability at the end of
>> the installation to optionally download and install LuaRocks (the lua
>> package manager). I have written a Lua script to download and run it
>> by calling Powershell commands from within lua. I have tested it
>> running under program files and set up the installer to add the
>> scripts. I have also turned Set-ExecutionPolicy to Default.
>>
>> My installer add files here:
>>
>> c:\Program Files\WinLua\Lua\5.3\
>>
>> \bin - lua.exe
>> \tools fetch-luarocks.lua
>>
>> The target directory for LuaRocks also under my installed application
>> path with a final installed product like such:
>>
>>     Directory: C:\Program Files\WinLua\lua\5.3
>>
>>
>> Mode                LastWriteTime         Length Name
>> ----                -------------         ------ ----
>> d-----       2018-01-31  10:20 PM                bin
>> d-----       2018-01-31  10:20 PM                include
>> d-----       2018-01-29  10:11 PM                LuaRocks
>> d-----       2018-01-31  10:20 PM                staticlib
>> d-----       2018-01-31  10:20 PM                tools
>>
>> I have created a CustomAction hoping to execute the newly installed
>> Lua and call the lua script file in the tools directory. I don't know
>> how to us a relative path to the installation so I don't think the
>> script is being found? My custom action is this:
>>
>>     <CustomAction Id="RunLua"
>>                   FileKey="lua.exe"
>>                   Win64="no"
>>                   ExeCommand="..\tools\fetch-luarocks.lua -u" />
>>     <InstallExecuteSequence>
>>       <Custom Action="RunLua" After="InstallFinalize" />
>>     </InstallExecuteSequence>
>>
>>
>> I turned on debugging in the MSI and the relevant part is this:
>>
>> Action ended 22:20:20: InstallFinalize. Return value 1.
>> MSI (s) (98:0C) [22:20:20:960]: Doing action: RunLua
>> MSI (s) (98:0C) [22:20:20:960]: Note: 1: 2205 2:  3: ActionText
>> Action 22:20:20: RunLua.
>> Action start 22:20:20: RunLua.
>> CustomAction RunLua returned actual error code 1 (note this may not be
>> 100% accurate if translation happened inside sandbox)
>> MSI (s) (98:0C) [22:20:21:109]: Note: 1: 1722 2: RunLua 3: C:\Program
>> Files\WinLua\Lua\5.3\bin\lua.exe 4: ..\tools\fetch-luarocks.lua -u
>> MSI (s) (98:0C) [22:20:21:109]: Note: 1: 2205 2:  3: Error
>> MSI (s) (98:0C) [22:20:21:109]: Note: 1: 2228 2:  3: Error 4: SELECT
>> `Message` FROM `Error` WHERE `Error` = 1722
>> Error 1722. There is a problem with this Windows Installer package. A
>> program run as part of the setup did not finish as expected. Contact
>> your support personnel or package vendor.  Action RunLua, location:
>> C:\Program Files\WinLua\Lua\5.3\bin\lua.exe, command:
>> ..\tools\fetch-luarocks.lua -u
>> MSI (s) (98:0C) [22:20:24:259]: Note: 1: 2205 2:  3: Error
>> MSI (s) (98:0C) [22:20:24:259]: Note: 1: 2228 2:  3: Error 4: SELECT
>> `Message` FROM `Error` WHERE `Error` = 1709
>> MSI (s) (98:0C) [22:20:24:259]: Product: Lua 5.3 64 Bit -- Error 1722.
>> There is a problem with this Windows Installer package. A program run
>> as part of the setup did not finish as expected. Contact your support
>> personnel or package vendor.  Action RunLua, location: C:\Program
>> Files\WinLua\Lua\5.3\bin\lua.exe, command: ..\tools\fetch-luarocks.lua
>> -u
>>
>> Action ended 22:20:24: RunLua. Return value 3.
>> Action ended 22:20:24: INSTALL. Return value 3.
>>
>> The full output of the log file is here: https://pastebin.com/LG7zFuKm
>>
>> Any input would be great.
>>
>> A secondary problem I have is that the installer will try to run the
>> script again on uninstall. I am hoping there is a way to differentiate
>> between installation and removal in a custom action? Any input would
>> be great as I'm new to custom actions.
>>
>> The full installer sources are here:
>>
>> https://github.com/WinLua/WinLua-VisualStudio/tree/master/Visual%20Studio/WinLua-Installer
>>
>> Cheers,
>>
>> Russell



More information about the wix-users mailing list