Is there any way to create .exe or .bat files using PHP?
Moderator: General Moderators
Is there any way to create .exe or .bat files using PHP?
Is there any way to create .exe or .bat files using PHP.
I do not know C++ or VB and am loathe to begin confusing myself with this if not necessary...which I suspect it is.
I do not know C++ or VB and am loathe to begin confusing myself with this if not necessary...which I suspect it is.
- MrNonchalant
- Forum Commoner
- Posts: 29
- Joined: Wed Jul 17, 2002 2:15 am
.bat files are basically text files with the .bat file extension instead of the .txt. To create and write to .bat files code like this should work:
Code: Select all
<?php
$fp = fopen("file.bat","a");
fwrite($fp,"@color 0A\n@echo The matrix has you, neo...");
fclose($fp);
if (file_exists("file.bat")) {
echo "Success.";
}
?>I beleive the OP is asking about using PHP to create an executable. This is possible if, and only if, you have a command-line version of PHP installed. It also means that anyone you want to distribute the executable to has to have a copy of a command-line php installed.
There is currently not a standard way to "package" the interpreter with a script to produce a pure binary.
There is currently not a standard way to "package" the interpreter with a script to produce a pure binary.
The purpose of the .exe file was to compile a screensaver from a javascript page and series of images, and have this downloadable to a clients' PC.
I don't think an average man on the street is going to want to be bothered with command-line PHP.
Cheers for the replys though, I wanted to avoid learnng any C++ to be honest!
I don't think an average man on the street is going to want to be bothered with command-line PHP.
Cheers for the replys though, I wanted to avoid learnng any C++ to be honest!
It's not the average man on the street that will be bothered, it is you, if you are writing the script.
So, now that we know PHP will NOT be creating the exe, but a compiler, how does that compiler work, what is it written in?
I believe nielsene is partially right in this case. My ISP did not compile imagemajick into PHP, so I run it externally with the exec() command. You could do the same with your compiler, and scoop up the results for your clients.
So, now that we know PHP will NOT be creating the exe, but a compiler, how does that compiler work, what is it written in?
I believe nielsene is partially right in this case. My ISP did not compile imagemajick into PHP, so I run it externally with the exec() command. You could do the same with your compiler, and scoop up the results for your clients.
jmarcv, cheers for the help.
I think I have overestimated my abilities...I have come to development through design and so have little programming experience to fall back on.
I was hoping to compile the .exe file in PHP as this is the only programming language I know ( besides the basic web design elements of html and javascript and so on).
I have looked at the earlier suggestion of command line PHP and this looks approachable...
Basically I want to stick a javascript page which moves images about, in the same directory as a load of images, and compile all this into one file which can be downloaded and installed on the users PC.
If I can create this compiling effect using command line PHP I will look into it, otherwise I might have to admit defeat for the moment...this level of development is a bit alien to me for the time being.
I think I have overestimated my abilities...I have come to development through design and so have little programming experience to fall back on.
I was hoping to compile the .exe file in PHP as this is the only programming language I know ( besides the basic web design elements of html and javascript and so on).
I have looked at the earlier suggestion of command line PHP and this looks approachable...
Basically I want to stick a javascript page which moves images about, in the same directory as a load of images, and compile all this into one file which can be downloaded and installed on the users PC.
If I can create this compiling effect using command line PHP I will look into it, otherwise I might have to admit defeat for the moment...this level of development is a bit alien to me for the time being.
OK, well these easiest way to 'compile' this is to copy all the files necessary to a temp folder and create links for every file to download.
Otherwise, if your php has the ability to create zip files, you can do it that way and create just ONE link.
All this can be done from PHP without command mode.
Otherwise, if your php has the ability to create zip files, you can do it that way and create just ONE link.
All this can be done from PHP without command mode.