Converting .bat to .exe with no additional external software (Create SFX)
All windows machines with .NET installed come with files called vbc.exe, csc.exe & jsc.exe, at %windir%\Microsoft.NET\Framework (for 32bits) or Framework64 (for 64 bits), in a folder name starting with "v".
Guide on C# compiler:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/command-line-building-with-csc-exe
Guide on Visual Basic compiler:
https://docs.microsoft.com/en-us/dotnet/visual-basic/reference/command-line-compiler/index
Sample commands:
https://docs.microsoft.com/en-us/dotnet/visual-basic/reference/command-line-compiler/sample-compilation-command-lines
A Jscripting guide:
http://www.phpied.com/make-your-javascript-a-windows-exe/
A simple walkthrough from @Itchy to bundle a batch file to exe file with csc.exe:
How can a .bat file be 'converted' to .exe without third party tools?
In the same folder, a file called ngen.exe may also be found, which "generates native code so the application does not need to go through the just-in-time compilation process at runtime".
See:
https://books.google.com.au/books?id=iZM1jyqiyakC&pg=PA453&lpg=PA453&dq=guide++vbc.exe&source=bl&ots=UB041mSfni&sig=ACfU3U0xtmS8X9p0eDKD-u6bt-WvOVCbmQ&hl=en&sa=X&ved=2ahUKEwjshc6589_lAhXXXSsKHcTaBlUQ6AEwD3oECAYQAQ#v=onepage&q=guide%20%20vbc.exe&f=false
Refer to this How can a .bat file be 'converted' to .exe without third party tools?
The original script accepts two arguments - the .bat file you want to convert and the target executable.
I made a little modification to accept one argument : Just the .bat file you want to convert.
So in this case, you can drag and drop your batch file over this script bat2exeIEXP.bat and it will be converted to exe file with the same name as the batch file.
;@echo off
;Title Converting batch scripts to file.exe with iexpress
;Mode 75,3 & color 0A
;Rem Original Script https://github.com/npocmaka/batch.scripts/edit/master/hybrids/iexpress/bat2exeIEXP.bat
;echo(
;if "%~1" equ "" (
;echo Usage : Drag and Drop your batch file over this script:"%~nx0"
;Timeout /T 5 /nobreak>nul & Exit
;)
;set "target.exe=%__cd__%%~n1.exe"
;set "batch_file=%~f1"
;set "bat_name=%~nx1"
;set "bat_dir=%~dp1"
;Set "sed=%temp%\2exe.sed"
;echo Please wait a while ... Creating "%~n1.exe" ...
;copy /y "%~f0" "%sed%" >nul
;(
;(echo()
;(echo(AppLaunched=cmd /c "%bat_name%")
;(echo(TargetName=%target.exe%)
;(echo(FILE0="%bat_name%")
;(echo([SourceFiles])
;(echo(SourceFiles0=%bat_dir%)
;(echo([SourceFiles0])
;(echo(%%FILE0%%=)
;)>>"%sed%"
;iexpress /n /q /m %sed%
;del /q /f "%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=<None>
AdminQuietInstCmd=