Wix error 1721 related to CustomAction
Asked Answered
C

3

7

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.

Cholecyst answered 10/8, 2012 at 6:42 Comment(1)
Did you figure this out? I am having a similar issue with a custom action driver installation.X
B
6

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.

Beitch answered 10/8, 2012 at 8:45 Comment(1)
Adding After='InstallFinalize' gave me an error: "...is a in-script custom action. It must be sequenced in between the InstallInitialize action and the InstallFinalize action in the InstallExecuteSequence table"Crosley
O
5

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>
Oswell answered 19/2, 2013 at 20:34 Comment(0)
B
3

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.

Barbiturism answered 11/8, 2012 at 14:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.