私の目標は、.msiと同じフォルダーにある.batスクリプトを実行する以外に何もしないはずの単純なmsiパッケージを作成することです。ターゲットマシンにファイルをコピーしたり、フォルダを作成したりする必要はありません。必要な.batを実行するvb-scriptでWix3.5を使用しようとしました。vbコード自体は完全に機能しますが、.msi内では奇妙な方法で動作します。「パス」が付いたメッセージボックスが表示され、エラーは発生しませんが、スクリプトは.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>
私も別の方法を試しました:
<Property Id='CMD'>cmd.exe</Property>
<CustomAction Id='LaunchFile' Property='CMD' ExeCommand='[SourceDir]sample.bat' Return='check' Impersonate='yes'/>
しかし、プロパティに「notepad.exe」を入れると、すべてがうまく機能します。「cmd.exe」を使用すると、sample.batを実行せずにコンソールが開いたり閉じたりします。'notepad.exe'の場合、'sample.bat'の内容が表示されます。皆さん、これを手伝ってくれませんか?