Packaging .exe and batch script in an exe

July 15, 2010 at 09:37:14
Specs: Windows

I have few files [4 executables (.exe) along with a Windows batch script], which I need to package in a single exe. Of these 4 .exe files, 2 have to be transferred to a remote location. This transfer is handled by the Windows batch script.

The main file here is the Windows batch file, which will use all other exe files during its execution. I need to prepare an exe, which when clicked, should call the batch file.

Can anyone suggest any packaging tool for achieving my purpose?


See More: Packaging .exe and batch script in an exe

Report •

July 15, 2010 at 11:27:42
zip the exe files, and your main batchfile (f/e: b.bat), f./e into:
"pkzip exes b.bat one.exe two.exe three.exe four.exe"

make a batchfile, f/e a.bat:
pkunzip a.bat

then: copy /b a.bat + a.bat

then when you run a.bat, it will unzip and execute the b.bat batchfile contained in the zip. of course, unfort, you're still depending on the unzip utility to be available. other route is to make a self-extracting zip, but then you'd need to invoke the enclosed bat file manually (two step or two-file process)

i became interested in the problem, and wrote this bat which does require debug assistance, but pkunzip is now included in the package:
@echo off & setlocal enabledelayedexpansion
set a=M
for /f "tokens=1-3 delims=:" %%a in ('findstr /o "%a%Z" %0.bat ^|find ":%a%Z"') do set x=%%a
set hex=0123456789abcdef
set /a a="x%%16"
set out=!hex:~%a%,1!%out%
set /a x/=16
set /a a="x%%16"
set out=!hex:~%a%,1!%out%
set /a x/=16
set /a a="x%%16"
set out=!hex:~%a%,1!%out%
(echo ne
echo w%out%
echo q) | debug %0.bat
ren e pkun.exe
pkun -v pkun.exe
goto :eof
::-------- end

copy /b selfex.bat + pkunzip.exe + selfex.bat

when run, selfex removes itself from the two joined binaries, then uses binary1 (pkunzip) to unzip binary2 (the target files)
the demo above doesn't actually unzip, but just does a listing, for testing/verification purposes. remove the -v switch from the pkun line for actual use.

Report •

July 16, 2010 at 10:39:04
I really like nbrane's idea as its more ingenuitive and can be done without any additional purchase/tools.

With that said - I use and love Quick Batch File Compiler for exactly this purpose.

Report •

July 20, 2010 at 08:39:36

First of all, my sincere apologies to both of you for delay in my reply. I was stuck in some other issue, hence the delay.

@nbrane: Thank you for the detailed reply and the pain you took to write it. I went to the PKZIP site but looks like, it’s an evaluation copy. I guess, both the methods you've mentioned can be achieved using 7-zip as well, which is free. I’ll go for your first method; for the second one, I need to understand your program a bit as I am not much comfortable on Windows Batch scripting. I am still learning. Frankly, I could not give it a try right now using 7-zip but will surely try later as that method is simple to use.

@viddywell: Thanks a lot for the pointer! Even I have fallen in love with Quick Batch File Compiler. :) It’s exactly what I was looking for!

Thanks again to both of you for your time & suggestions.


Report •
Related Solutions

Ask Question