My goal is to create a simple msi package that is supposed to do nothing but running a .bat script located in the same folder with the .msi. I don’t need to copy any files on target machine or create folders, etc. I tried to use Wix 3.5 with vb-script which will run .bat i need. The vb-code itself works perfectly, but inside .msi it acts in a strange way – i can see a message box with the ‘path’, i got no errors, but script doesn’t execute .bat.
<Property Id="Launch">
<![CDATA[
Function Main()
Set shell = CreateObject("WSCript.shell")
path = Session.Property("SourceDir")
MsgBox path
shell.Run path & "sample.bat", 0, False
Set shell = Nothing
Main = 1
End Function
]]>
</Property>
<CustomAction Id="Die"
VBScriptCall="Main"
Property="Launch"
Return="check"
Impersonate="yes"/>
<InstallExecuteSequence>
<Custom Action='Die' Before='RegisterProduct'> NOT Installed </Custom>
</InstallExecuteSequence>
I also tried another way:
<Property Id='CMD'>cmd.exe</Property>
<CustomAction Id='LaunchFile' Property='CMD' ExeCommand='[SourceDir]sample.bat' Return='check' Impersonate='yes'/>
But if I put ‘notepad.exe’ in property – everythings works great, when I use ‘cmd.exe’ console opens and closes without executing my sample.bat. In case of ‘notepad.exe’, it shows the content of ‘sample.bat’. Could you guys help me out with this?
Well, that was easy… Actually, everything was ok, but .bat itself was calculating relative paths from
%WinDir%\System32\I just putCD %~dp0as the first line of my .bat and it started to work properly.