Wix error 1721 related to CustomAction

6.3k views Asked by At

I have following CostomAction

<Binary Id='ManualsBat' SourceFile='bin\Debug\test.bat' />

<CustomAction 
  Id="manuals"
  BinaryKey="ManualsBat"
  ExeCommand="[SourceDir]Manuals &quot;[Agent]Manuals&quot;"
  Execute="immediate"
  Return="check" />

test.bat contains the following lines :

@echo off
echo Hello this a test batch file
pause
mkdir %2
copy %1 %2

What it is basically intended to do is, when the installer is run, the batch file needs to get executed. The batch file has to create a new directory "[Agent]Manuals" and it has to copy all the files from [SourceDir]Manuals to [Agent]Manuals.

When I builds .wxs it does not give any error bur when I run the .msi then it complains of the following in the log files

Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: manuals, location: C:\Windows\Installer\MSI1F50.tmp, command: C:\dev\CD\Agent\pd\components\link\source\Link\Installer\WiX\WiX\bin\Debug\Manuals "D:\Cam\city\Agent\Manuals

Has anyone had experience with this kind of error. It will be great if someone can help me resolve this.

3

There are 3 answers

1
Cosmin On

Most likely your custom action needs Administrator privileges. Try setting Execute attribute to deferred and Impersonate to no. Please note that these options require the action to be scheduled after InstallFinalize standard action.

0
Christopher Painter On

You generally need to call cmd /c foo.bat ( or command on Win9x ) to process .bat files.

However, I would never, ever do this in one of my installers. It violates the overall design on Windows Installer. MSI is a transactional, declarative programming language. Injecting out of process procedural code greatly increases the likelyhood of failure ( as you are experiencing ) and worse defeats the transactional benefits of MSI.

For example, if you create a folder and copy a file, that won't get undone during a rollback and it won't get removed during an uninstall. Instead, you should be using the built in Windows Installer features ( CreateFolder and CopyFile elements ) to achieve your goals.

On the occasion that custom actions are truely needed (in your example you are merely reinventing the wheel with an inferior solution) they should be designed using robust languages and maintaining a declarative (data driven) and transactional design while respecting the security model that MSI uses.

0
Sergik666 On

Maybe problem in quotes. Change in ExeCommand quotes. Try this:

<Binary Id='ManualsBat' SourceFile='bin\Debug\test.bat' />

<CustomAction 
  Id="manuals"
  BinaryKey="ManualsBat"
  ExeCommand='"[SourceDir]Manuals" "[Agent]Manuals"'
  Execute="deferred"
  Impersonate="no"
  Return="check" />

<InstallExecuteSequence>
  <Custom Action="manuals" Before="InstallFinalize">Not Installed</Custom>
</InstallExecuteSequence>