Home » How To » How to Convert a “.bat” File to “.exe” Without Using Third Party Tools

How to Convert a “.bat” File to “.exe” Without Using Third Party Tools

Here is How to Convert a “.bat” File to “.exe” Without Using Third Party Tools? 

We will use IEXPRESS – this is a Windows built-in tool that creates self-extracting packages and is capable to execute post-extraction commands. So here’s IEXPRESS sed-directive/.bat file that creates a self-extracting .exe with packed .bat. It accepts two arguments – the .bat file you want to convert and the target .exe executable you wanted to create.

Step 1:

Save the below code as a .bat file for example bat2exe.bat.

;@echo off
;if "%~2" equ "" (
; echo usage: %~nx0 batFile.bat target.Exe
;)
;set "target.exe=%__cd__%%~2"
;set "batch_file=%~f1"
;set "bat_name=%~nx1"
;set "bat_dir=%~dp1"

;copy /y "%~f0" "%temp%\2exe.sed" >nul

;(echo()>>"%temp%\2exe.sed"
;(echo(AppLaunched=cmd.exe /c "%bat_name%")>>"%temp%\2exe.sed"
;(echo(TargetName=%target.exe%)>>"%temp%\2exe.sed"
;(echo(FILE0="%bat_name%")>>"%temp%\2exe.sed"
;(echo([SourceFiles])>>"%temp%\2exe.sed"
;(echo(SourceFiles0=%bat_dir%)>>"%temp%\2exe.sed"
;(echo([SourceFiles0])>>"%temp%\2exe.sed"
;(echo(%%FILE0%%=)>>"%temp%\2exe.sed"


;iexpress /n /q /m %temp%\2exe.sed

;del /q /f "%temp%\2exe.sed"
;exit /b 0

[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=1
UseLongFileName=1
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=
DisplayLicense=
FinishMessage=
FriendlyName=-
PostInstallCmd=
AdminQuietInstCmd=
UserQuietInstCmd=

Step 2:

Make sure you have your “.bat” file in the same folder that you wanted to convert for example mytechmint.bat

Step 3:

Now open Command Prompt in the same folder where you have your bat2exe.bat and mytechmint.bat files and execute the below command.

bat2exe.bat mytechmint.bat mytechmint.exe 

bat2exe-mytechmint

Now you have one extra file generated in the same folder with the file name mytechmint.exe (converted file).

Related:  How to Create Restore Point in Windows 10

So now we have successfully converted a “.bat” file to a “.exe” file without using any third-party software. 😎

 

Leave a Comment