Nariman Esmaiely Fard
Nariman Esmaiely Fard

Reputation: 615

WIX CustomAction terminates with error 1721 or 1722

I'm trying to create a MSI installer for my application which is a customized elasticsearch. I need to run elasticsearch-service.bat install command from cmd in the middle of installation. But whatever I do it will not execute successfully.

<CustomAction Id="InstallService" Directory="elasticsearch" Execute="deferred" Impersonate="no" ExeCommand='[SystemFolder] cmd.exe /c "bin\elasticsearch-service.bat install"' Return="check" />

<InstallExecuteSequence>
  <Custom Action="InstallService" After="InstallFiles" />
</InstallExecuteSequence>

1721 and 1722 errors are vague and do not contain any additional information. What is the reason for these error? I was suspicious that these errors are due to lack of admin privileges. But I add InstallPrivileges=elevated and InstallScope=perMachine to package element and still getting the same error.

Upvotes: 1

Views: 706

Answers (1)

zett42
zett42

Reputation: 27756

I agree with Stein, that you should use the built-in facilities of MSI/WiX to install the service, namely the <ServiceInstall> and <ServiceConfig> elements.

That being said, these are the errors of your current solution:

  • Space between [SystemFolder] and cmd.exe.
  • Executable path is not quoted.
  • Relative path to .bat file. Very fragile.

Possible solution:

<CustomAction Id="InstallService" Directory="elasticsearch" Execute="deferred" Impersonate="no" ExeCommand='"[elasticsearch]bin\elasticsearch-service.bat" install' Return="check" />

You can call a batch file directly, without passing it to cmd.exe.

Upvotes: 1

Related Questions