1

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%=
gaurav2907
  • 51
  • 1
  • 9
  • echo off set "workdir=C:\install\my" mkdir %workdir% powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://www.python.org/ftp/python/3.6.1/python-3.6.1.exe', '%workdir%\pyinstaller.exe')" set "python_ver=(not found)" for /f "delims=" %%i in ('python -V') do set python_ver=%%i :: don't check for specific versions in the output - just that it exists if not "%python_ver%"=="%python_ver:Python =%" ( echo Python found in system path. Checking for pip.... ) else ( echo Python not installed correctly! Please check version and path exit /b ) – gaurav2907 Jul 18 '18 at 13:17
  • 1
    Thanks for the extra information. It's best to edit it into your question (formatted nicely), then it's easier for new people looking at your question to find it and help you and improve the quality of your question ;) – Ian Jul 18 '18 at 13:22
  • i think its much clear. – gaurav2907 Jul 18 '18 at 13:35
  • What is the output that you get, exactly? – Ian Jul 18 '18 at 13:41
  • nothing i double click on the exe created using iexpress and nothing happens. Actually i create another exe from another bat file which has only content as @echo off echo %DATE% >> "C:\Users\gaubansa\Desktop\my.txt" echo %PATH% >> "C:\Users\gaubansa\Desktop\my.txt" . nothing happens in this case also. – gaurav2907 Jul 18 '18 at 13:53
  • It would have been significantly better, especially given that you're supposed to post a [mcve], to **replace all of the code in your question with the much shorter failing code from your comment directly above**. I have therefore done so! You also state that you `'followed all the steps'`, which steps? can you list them in your question? or at least provide a link – Compo Jul 18 '18 at 14:44
  • 1
    Do you cat any error? Iexpress by default tries to run the bat files through command.com and to run it on a modern machines you have to call it with `cmd.exe /c example.bat` – npocmaka Jul 18 '18 at 14:58
  • @npocmaka, yes I believe you have that in your [Bat to Exe QA](https://stackoverflow.com/questions/28174386/how-can-a-bat-file-be-converted-to-exe-without-third-party-tools) – Squashman Jul 18 '18 at 15:07
  • i followed all the iexpress steps including the specifically mention to run it in a cmd.exe /c myproject.bat and used the echo Failed with error #%errorlevel%. exit /b %errorlevel% exit /b %errorlevel% still nothing happens. – gaurav2907 Jul 19 '18 at 05:58

1 Answers1

1

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"

sst
  • 1,443
  • 1
  • 12
  • 15
  • Thanks it worked. Can we pass arguments to the .EXE created using iexpress. – gaurav2907 Jul 20 '18 at 06:28
  • @sst How can I change/tweak the .sed file and use IExpress to generate reliable and working executables of Self-Elevating(UAC Popup firing from within the script) Batch scripts / utilities ? – Vicky Dev Feb 21 '21 at 01:09
  • @VickyDev You can't do that by the .sed file. You need a PE resource editor like Resource Hacker, to edit the application manifest of the output package and make the necessary changes. – sst Feb 21 '21 at 16:39