开发者

Running copied files in WiX using a custom action

开发者 https://www.devze.com 2023-01-21 23:48 出处:网络
I\'m creating an MSI installer using WiX and I have, say, a *.bat file that I\'m copying to SomeFolder2 under %temp% (something like the code snippet below...)

I'm creating an MSI installer using WiX and I have, say, a *.bat file that I'm copying to SomeFolder2 under %temp% (something like the code snippet below...)

...

<Directory Id='TARGETDIR' Name='SourceDir'>
    <Directory Id='ProgramFilesFolder' Name='PFiles'>
       <Directory Id='MyDir' Name='SomeFolder'>

           <!-- %TEMP -->
           <Directory Id="TempFolder" Name="TmpFolder">
               <Directory Id='MyDir2' Name='SomeFolder2'>

                   <!-- CREATE THE %TEMP%\SomeFolder2 FOLDER -->
                   <Component Id='FolderComponent' Guid='{GUID}'>
                       <CreateFolder />
                   </Component>

                   <Component Id='CheckComponent' Guid='{GUID}'>
                       <File Id='mybat' Name='mybat.bat' DiskId='1' Source='.\mybat.bat' KeyPath="yes">
                           <Shortcut Id="mybatShcut"
                                     Directory="ProgramMenuDir"
                                     Name="{name}"
                                     WorkingDirectory='INSTALLDIR'
                                     Advertise="yes" />
                       </File>
                   </Component>
               </Directory>
           </Directory>
       </Directory>
    </Directory>
</Directory>

...

Now, to run this, I have two custom actions (DESTDIR is %TEMP%\SomeFolder2):

<CustomAction Id="SetPath" Property="ThePath" Value="[DESTDIR]\mybat.bat" />
<CustomAction Id="StartAction" Property="ThePath" ExeCommand="" Return="asyncNoWait" />

Then in the install sequence:

<InstallExecuteSequence>
    <Custom Action="SetPath" After="{so开发者_如何学Cme standard MS action}">NOT REMOVE="ALL"</Custom>
    <Custom Action="StartAction" Before="{some other action}">NOT REMOVE="ALL"</Custom>
    ...
</InstallExecuteSequence>

I've put SetPath to run after a variety of standard actions (for example, PublishProduct) while StartAction will come before another custom action.

When I run the MSI file, I look in the log and ThePath does get set with the correct path. However, when StartAction is run, I get this error:

Return value 1631.

which, according to the documentation, translate to "ERROR_CREATE_FAILED" (the Windows Installer service failed to start. Contact your support personnel). The thing is, the file did get copied to %TEMP%\SomeFolder2 (before the setting of the path and the actual exection, might I add...), but for some reason, it doesn't execute at all (if you do execute it manually or via the command prompt or whatnot, it does execute normally).

I tried putting the same file under ProgramFiles\Some_Directory_For_The_Program. The same thing happens; it gets copied there, but it doesn't execute. Why is this happening?


First off, as long as you'd like to use a file installed by your package in a custom action, you should make it deferred. That is, StartAction CA in your example must be deferred. Also, I try to use QtExec standard CA when I need to run executables from CA.

I hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号