Link to home
Create AccountLog in
Avatar of JapyDooge
JapyDoogeFlag for Netherlands

asked on

[PHP and Batch] Save files as a self-extracting executable

Hi collegeues,

In PHP i'm creating a bunch of batch files (based on what settings a user gives) that need to be downloaded and executed on the users computer.
I trought it would be nice if the user only has to download an executable file that is a self extracting archive and contains a bunch of batch files and other tools.

The self extracting file has to:
 - Extract to a given path without asking the user for it, for example c:\insttemp
 - Run a batch file after extraction, for example: c:\insttemp\start1.cmd
 - Have no user interaction (unattended, so not even a confirmation) so a user is'nt able to do it wrong, just download and run.

I am able to create such a file using 7z (7zip command line utility) and an executable header i can copy in front of the file: (copy /b header.bin + settings.cfg + archive.7z executable.exe) but i dont think this is a very nice and stable solution.
This way i have to:
 - Safe all the files from php in a temp folder on the server
 - exec("7z blah blah") to archive them
 - exec("copy /b blah blah") to make it self extracting
 - Offer the file for downloading

I know i can save files to a .zip archive in php directly, wich is already way more stable, but i cant convert a zip file to a 7z file without unpacking it, so exact the same problem, even more steps.
I know i can make a self extracting file from a zip file using command line tools, but i cant give them the exact extracting path and a file to run afterwards _without_ user interaction (well i did'nt find one yet and looked up over 50 different tools).

Anyone has an idea to make this nice?
ASKER CERTIFIED SOLUTION
Avatar of eagle00789
eagle00789
Flag of Netherlands image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of JapyDooge

ASKER

Hmm thanks, that's not a bad idea. Becouse it's one file theres less changes it fails becouse something was'nt finished yet...
I'll hold this question open for a few more hours to see if someone else maybe has a great idea, otherwise i'll do it that way (well i would slightly change it but i got the idea).
And so be it :)
Not exactly were i was looking for, but it does the job after all ;-) Thanks!