windowsbatch-fileexeiexpress

Batch file wrapped as an IExpress executable does not run properly


I have used iexpress to wrap a .bat file within an .EXE file.

The .bat file contains commands to install my project on Windows.

I followed all the steps and I got an .exe file, but when run it shows a finished msg but nothing is done. (no command inside the bat file is running).

@echo off
echo %DATE% >> "C:\Users\gaubansa\Desktop\my.txt"
echo %PATH% >> "C:\Users\gaubansa\Desktop\my.txt"

Cotnets of the .SED file:

[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=1
HideExtractAnimation=0
UseLongFileName=0
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=Write
DisplayLicense=
FinishMessage=ho gya
TargetName=C:\Users\gaubansa\Desktop\my.EXE
FriendlyName=Write
AppLaunched=cmd.exe /c my_personal.bat
PostInstallCmd=<None>
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="my_personal.bat"
[SourceFiles]
SourceFiles0=C:\Users\gaubansa\Desktop\
[SourceFiles0]
%FILE0%=

Solution

  • According to the Iexpress directive (.SED) file you posted, the problem is that you configured Iexpress to store file names in the package using short file names so your batch file my_personal.bat will be stored in the package using its short file name MY_PER~1.BAT but you have specified cmd /c my_personal.bat to run your batch file so cmd can not find my_personal.bat.

    To resolve that choose the option Store files using Long File Name inside Package in Iexpress. Alternatively you can edit the SED file and change the directive UseLongFileName=0 to UseLongFileName=1 then in Iexpress GUI select Open existing Self Extraction Directive file

    Some additional advise

    Although your batch file name does not contain spaces or other special characters it is always a good practice to enclose the file name in quotes. So you should change AppLaunched=cmd.exe /c my_personal.bat to AppLaunched=cmd.exe /d /c "my_personal.bat"
    The /d switch is optional, it is to prevent cmd from executing commands that may be present cmd's AutoRun registry settings. You can get more information about it by typing CMD /? at command prompt.

    A safer option would be use AppLaunched=cmd.exe /d /s /c ""my_personal.bat"" so in future if you ever decide to repackage your batch file and pass some quoted parameter to it, you can do that without the risk of essential quotation marks being removed by cmd.

    for example: cmd.exe /d /s /c ""my_personal.bat" "Quoted Param1" "Quoted Param2" UnquotedParam3"