What's wrong with my custom Action?

1

I've tried tons of times to try to use a custom action just to simply copy a file to another place. I do think this should be easily worked, but... I was frustrated that it is always failed!

I post my code and the error log, please any one kindly enough to point me the way out... Thank you in advance!!

   <CustomAction Id="QtExecCopyPropertyFileCmd"
                 Property="QtExec64CmdLine" 
                 Value="&quot;[SystemFolder]cmd.exe&quot; /c copy &quot;C:\Program Files\AptWare\AptWare View\Server\broker\webapps\portal\WEB-INF\classes\portal-links.properties&quot; &quot;C:\ProgramData\AptWare\VDM&quot;"/>
  <CustomAction Id="QtExecCopyPropertyFile"
                BinaryKey="WixCA"
                DllEntry="CAQuietExec64"
                Execute="immidiate"
                Return="check"/>

And here is my action sequence:

 <InstallExecuteSequence>
     <Custom Action='SetOldPortalLinkFile' After='InstallInitialize'>NOT (Installed OR PORTALLINKFILEEXISTS) AND OLDPORTALLINKFILEEXISTS</Custom>
     <Custom Action='SetPortalLinkFileDestFolder' After='SetOldPortalLinkFile'>NOT (Installed OR PORTALLINKFILEEXISTS) AND OLDPORTALLINKFILEEXISTS</Custom>
     <Custom Action="QtExecCopyPropertyFileCmd" After="SetPortalLinkFileDestFolder">NOT (Installed OR PORTALLINKFILEEXISTS) AND OLDPORTALLINKFILEEXISTS</Custom>
     <Custom Action="QtExecCopyPropertyFile" After="QtExecCopyPropertyFileCmd">NOT (Installed OR PORTALLINKFILEEXISTS) AND OLDPORTALLINKFILEEXISTS</Custom>

And some approach I've tried:

  1. I do not think this is due to quto, or file/dir existence, from the log I copied the generated cmd running in a cmd shell it works
  2. It is not related with 32bit or 64bit CA, I tried both 32 and 64 bit. All same failure.
  3. I am not sure if this relate with privilege, but if I try deferred CA, still I got error... And in my scenario I need a immediate CA because the copied file will be removed during uninstall previous version. So I need it run before InstallFinalized

The last, error log:

操作 6:22:34: QtExecCopyPropertyFileCmd。

操作开始 6:22:34: QtExecCopyPropertyFileCmd。

MSI (s) (90:88) [06:22:34:743]: Transforming table CustomAction.

MSI (s) (90:88) [06:22:34:743]: PROPERTY CHANGE: Adding QtExec64CmdLine property. Its value is '"C:\Windows\SysWOW64\cmd.exe" /c copy "C:\Program Files\AptWare\AptWare View\Server\broker\webapps\portal\WEB-INF\classes\portal-links.properties" "C:\ProgramData\AptWare\VDM"'.

操作结束 6:22:34: QtExecCopyPropertyFileCmd。返回值 1。

MSI (s) (90:88) [06:22:34:743]: Doing action: QtExecCopyPropertyFile

操作 6:22:34: QtExecCopyPropertyFile。

操作开始 6:22:34: QtExecCopyPropertyFile。

MSI (s) (90:88) [06:22:34:746]: Transforming table CustomAction.

MSI (s) (90:98) [06:22:34:748]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIB138.tmp, Entrypoint: CAQuietExec64

MSI (s) (90:2C) [06:22:34:762]: PROPERTY CHANGE: Deleting QtExec64CmdLine property. Its current value is '"C:\Windows\SysWOW64\cmd.exe" /c copy "C:\Program Files\AptWare\AptWare View\Server\broker\webapps\portal\WEB-INF\classes\portal-links.properties" "C:\ProgramData\AptWare\VDM"'.

CAQuietExec64:  Error 0x80070001: Command line returned an error.

CAQuietExec64:  Error 0x80070001: CAQuietExec64 Failed

CustomAction QtExecCopyPropertyFile returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
wix
cmd
execution
custom-action
asked on Stack Overflow Apr 24, 2013 by xwei • edited Apr 25, 2013 by Yan Sklyarenko

4 Answers

2

I go the answer now. http://sharp-gamedev.blogspot.com/2009/07/wix-again.html

In above link, clearly, CAQuietExec must have some bugs to support build in dos command such as copy, ren, del etc. However, use xcopy.exe instead of copy it work, I tested, it really work. I think for ren or del can find other substitutions as well.

What a big trap for me!!

Thanks all the kindly replied!

answered on Stack Overflow Apr 25, 2013 by xwei
1

As per my understand you need to copy file from your installation location to another location before uninstall the previous version in upgrade. Since the upgrade will remove all files are already installed. In that case try this code. If you schedule the Custom action before uninstall previous version it will work. I tried this with test project and its work for me.

<RemoveExistingProducts Before="InstallInitialize" />
<Custom Action="QtExecCopyPropertyFileCmd" After="AppSearch"> (NOT Installed)</Custom>
<Custom Action="QtExecCopyPropertyFile" After="QtExecCopyPropertyFileCmd"> (NOT Installed)</Custom>
answered on Stack Overflow Apr 25, 2013 by Vinoth
0

The thing I see "wrong" is that you wrote a custom action at all. The CopyFile element supports the use of the MoveFile table to teach MSI that this file needs to be copied. This will then fully support rollback, upgrade and uninstall stories. You lose all of that when you shell out of process to a dos command.

answered on Stack Overflow Apr 24, 2013 by Christopher Painter
0

Seems like you found your solution already.

But I am using copy almost exactly as you did, I think it might be worth sharing my solution for anyone do want use copy instead of xcopy. I did tried xcopy solution from your link, but for me, xcopy is more suitable for batch copy, on the other hand, I am copying single file and I also want define my own destinate file name but it is tricker to do using xcopy with CA (if possible).

For my project, I am using deferred Execute instead of immediate, immediate is possible as well, but the syntax will be different:

<!--Syntex for deferred-->
    <!--<Property Id='QtExecCA' Value='"cmd.exe" /c copy C:\temp\test.txt C:\temp\test2.txt' />-->
    <!--Syntex for immediate-->
    <Property Id='QtExecCmdLine' Value='"cmd.exe" /c copy C:\temp\test.txt C:\temp\test2.txt' /><CustomAction Id='QtExecTest' BinaryKey='WixCA' DllEntry='CAQuietExec'
              Execute='immediate' Return='check'/>
.
.
.
<InstallExecuteSequence>
  <Custom Action='QtExecCA' After='InstallInitialize'/>
</InstallExecuteSequence>

That is in essential my code for copy.

It took my a few tries to get QtExec syntax right, and I think that might be where you have problem.

Reference for QtExec

answered on Stack Overflow Mar 7, 2014 by Paul L • edited Mar 7, 2014 by Paul L

User contributions licensed under CC BY-SA 3.0