?
Solved

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

Posted on 2008-06-10
4
Medium Priority
?
384 Views
Last Modified: 2013-12-13
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?
0
Comment
Question by:JapyDooge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 1

Accepted Solution

by:
eagle00789 earned 2000 total points
ID: 21754868
the only viable solution i can give you is below in the code field. Make this into a batchfile you put on the server. that batchfile does everything in one go for you
When you save the contents below to a file, you can call it with "compressor.bat compressed c:\compressing"
What the code does is exactly what you code also does, but this file is the only one you need to call and does it all for you.
compressor <filename> <dir with files to compress>
also, make sure that the file config.txt is also in the dir with files to compress.
@echo off
echo Please wait while zipping the files...
7z a -t7z %2\%1.7z %2\*.* -x!config.txt
echo Please wait while creating the selfextractor
copy /b 7zS.sfx + %2\config.txt + %2\%1.7z %2\%1.exe

Open in new window

0
 
LVL 6

Author Comment

by:JapyDooge
ID: 21757701
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).
0
 
LVL 6

Author Comment

by:JapyDooge
ID: 21759813
And so be it :)
0
 
LVL 6

Author Closing Comment

by:JapyDooge
ID: 31465750
Not exactly were i was looking for, but it does the job after all ;-) Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question