Solved

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

Posted on 2008-06-10
4
381 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find computer name from username 9 107
How would I craft a PDO SELECT based on an IF Statement? 8 33
xml with php question 5 35
MySQL-Design Help 12 44
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

733 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