Install elasticsearch as service using wix - elasticsearch

I want to create an installer for a customized elasticsearch using WIX. When I use <CustomAction> to run elasticsearch-service.bat I get 1721 error. (I know that it is an antipattern to run bat files in your installer. But it seems the easiest way to install an elasticsearch service.)
<CustomAction Id="InstallService" Directory="elasticsearch" Execute="deferred" Impersonate="no" ExeCommand='"[elasticsearch]bin\elasticsearch-service.bat" install' Return="check" />
Also when I use <SerivceInstall> to create a service from elasticsearch-service-x64.exe, the service does not installed correctly and I can not start it. What is the best solution for doing this task?

Related

how to run WixSilentExecCmdLine to run batfil ein background

I am trying to run a bat file in background while installing an app using WIX. For this I used WixSilentExecCmdLine but after writing this code sniphet Installationitself failed.
<Property Id="WixSilentExecCmdLine" Value="C:\SampleWix\myBat.bat" Hidden="yes"/>
<CustomAction Id="SilentExecExample" BinaryKey="WixCA" DllEntry="WixSilentExec" Execute="immediate" Return="check"/>
<InstallExecuteSequence>
<Custom Action="SilentExecExample" Before="InstallFinalize"/>
</InstallExecuteSequence>
Light Command
%WIX_LIGHT% %INSTALLER_BUILD_DIR%\*.wixobj -o %OUTPUT_DIR%\%MSI_OUTPUT_FILE_NAME% -ext WixUIExtension -ext WixUtilExtension.dll
You will not be able to run another parallel install while in the ExecuteSequence. Windows installer has a limitation that only one install can be in the ExecuteSequence at one time.
Please see this thread.

Running Powershell script in WiX install as an Administrator

I have a WiX installer that needs to run a Powershell script after install. I've gotten to the point where the installer does in fact run the script with this:
<SetProperty Id="RunStartScript"
Before ="RunStartScript"
Sequence="execute"
Value=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NonInteractive -ExecutionPolicy Bypass -InputFormat None -NoProfile -File "[INSTALLDIR]Scripts/Start.ps1"" />
<CustomAction Id="RunStartScript" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="yes" />
<InstallExecuteSequence>
<Custom Action="RunStartScript" Before="InstallFinalize">NOT Installed OR UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>
However, the msi fails with this error:
The script 'Start.ps1' cannot be run because it contains a "#requires" statement for running as Administrator. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try running the script again.
The installer already prompts for an Administrator before install begins, so I assumed the PowerShell command would be running as an admin already, this must not be the case.
I've found some answers that involve adding code to the start of a script to check for Admin privileges and to pass the command and args along to an Admin session, but I was looking for the possibility of another option as this is a signed script that someone else provided so any changes to it would have to go back to them for re-signing.
Needed to change Impersonate="yes" to Impersonate="no" so that the Powershell session wasn't ran as the normal user.

How to write a condition tag for service search

I am using WIX to create MSI installers for C# services. The MSI does 3 jobs :
a) Copy solution file from bin to a particular location.
b) Create a folder where the service writes it's logs.
c) install the service on the machine if it previously does not exist.
I want to write a condition to check if the service has already been installed on the machine.
This is the registry search :
<Property Id="MYSERVICE">
<RegistrySearch Id="SERVICE_CHECK" Root="HKLM" Name="Install" Type="raw" Key="SYSTEM\CurrentControlSet\services\Service"/>
</Property>
This is the code for installing the service using custom action:
<Condition Message="service der already"><![CDATA[Installed OR (MYSERVICE <> Null)]]></Condition>
<InstallExecuteSequence>
<Custom Action='CMDInstallService' Before='InstallFinalize'></Custom>
</InstallExecuteSequence>
How do I write the condition, which will check that is the service exists then do nothing, else install the service.
Given the service is part of the product assigning it to its own feature will handle this.
The answer is this, the issue was with the syntax.
The syntax should have been
NOT SERVICE was the golden answer.

How can I conditionalize a WiX custom action based on user priviledges

I have an application that includes a shell that is displayed for all non-admin users. During installation the shell needs to be closed. However if anything goes wrong during installation, I would like the shell to be restarted via a custom action. For legacy reasons, I accomplish both the close and the restart via C# custom actions. Here is the WiX code:
<CustomAction Id="CA_StopShell" ... Execute="deferred" Impersonate="no"/>
<CustomAction Id="CA_StartRollbackShell" ... Execute="rollback" Impersonate="yes"/>
<InstallExecuteSequence>
<Custom Action="CA_StartRollbackShell" Before="CA_StopShell"> </Custom>
<Custom Action="CA_StopShell" After="ProcessComponents" />
</InstallExecuteSequence>
This works fine, but it also brings up the shell for the admin user when there is an install failure, which is bad. The question is how do I make the custom action only occur if the user was not the Admin user?
I tried:
<Custom Action="CA_StartRollbackShell" Before="CA_StopAllAADProcesses"> NOT Privileged </Custom>
But that didn't ever start the shell back up.
FYI, I'm using Wix 3.8.
Thanks for any help you can give.

Silent Install of Oracle using WiX

I am creating an Installer using WiX, and as part of this I am installing Oracle also.
I am using CA for doing this. But it fails without executing.
<CustomAction Id="InstallORA" ExeCommand="[ORACLE]start-oraclexe-install.bat" Directory="ORACLE" Execute="deferred" Return="check" Impersonate="no" />
My bat file content is:
C:\xe-10.2.0.1-nt.exe /s /f1"C:\OracleXE-install.iss" /f2"C:\oraclexe-setup.log"
In logs I see MSI (s) (44:9C) [12:18:42:344]: Running as a service. after this it pops an error message.
Any ideas how to fix it?

Resources