0
votes

I need to run a .bat file after .msi installation in Wix. I have created this .msi from Wix setup project.

In the .bat file, I have written scripts which edit the etc/hosts files and install some fonts into windows machine as per my application need.

Please help me to resolve my issue. Thanks.

2
Handling file modifications and installing fonts should be done by the installerMorten Frederiksen
@ Morten Frederiksen, Thanks for your answer. Would be great if you please let me know how can I handle file modifications and installing fonts by the installer using Wix. Btw, is it possible to run .bat file automatically after msi installation in Wix and if yes then how ? Have you any idea ?User2546

2 Answers

0
votes

It's possible to run a .BAT but that's really to do things like set up a java classpath and launch a java application. Not to make additional changes to the machine.

There are several issues with your design.

1) The UI sequence shouldn't run with elevated permissions so the .BAT won't have rights to do the things you want to do

2) The changes are being made outside of the installation transaction so there's no support for rollback or uninstall

3) The changes are being made by a script that has no support for logging or error handling. It'll be fragile.

4) Because the changes aren't expressed in Windows Intaller tables you loose the expressiveness and transformability that MSI provides.

The .BAT should be refactored and likely eliminated. The "how do I xyz?" questions for each thing it does (install a font, modify a file...) should each be their own StackOverflow question.

0
votes
    <CustomAction Id="RunBatch"                 
                  Execute="deferred" 
                  Return="ignore"             
                  Impersonate="no"              
                  ExeCommand="&quot;[SystemFolder]cmd.exe&quot; /C &quot;[INSTALLDIR]mybatchfile.bat&quot;"
                  Directory="INSTALLDIR"/>  

<InstallExecuteSequence>
  <Custom Action="RunBatch" Before="InstallFinalize"/>
</InstallExecuteSequence>