windows - How to create an EXE executable with batch file? -


this question has answer here:

i want able run windows batch file , have create .exe executable.

i know can create files following script in batch:

@echo off echo in text file! >> test.txt echo , second line! >> test.txt 

so wondering, possible copy source code of exe file , add "echo" in front of every line, , " >> test.exe" , end of every line?

i tried open 39kb .exe in notepad ++, bunch of black nul characters.

so i'm pretty asking if there's way embed files inside batch files? audio file maybe?

here's how can done certutil utility. in case demonstrated hard-coded path whoami.exe builtin command in windows.

first script creates .bat embedded .exe :

@echo off certutil -f -encode  %windir%\system32\whoami.exe whoami.b64 echo @echo off >container.bat echo certutil -decode "%%~f0" whoami.exe>>container.bat echo call whoami.exe>>container.bat echo exit /b %%errorlevel%%>>container.bat type whoami.b64>>container.bat del whoami.b64 

for exe you'll need change path exe.then container.bat should like:

@echo off  certutil -decode "%~f0" whoami.exe call whoami.exe exit /b %errorlevel% -----begin certificate----- ... ..base64 encoded content... ... -----end certificate---- 

certutil can encode/decode base64 , hex here base64 more convenient because can embedded batch enclosements (begin certificate , end certificate) , base64 encoded strings shorter hex ones.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -