Category — windows
How to turn a php script to an exe..for free
There are a few commercial products out there that allow you to turn your php scripts into an executable. While most of them work well, I have found a way to do it for free, using an open source application. This application is called Wapache (based on the apache web server) and it is open source (distributed under the Apache License 2.0).
WApache doesn’t convert your script directly into an executable, it runs on the combination of a windows app (which uses an embedded IE control) and a stripped down version of apache.
Features
- No Internet Explorer menu, tool bar, or address bar.
- Precise control over placement of windows
- Three types of windows: basic, tool windows, and dialog boxes (modal and modeless)
- Fully customizable drop-down and context menu
- System Tray integration
- Asynchronous data handling
- Works with standard Apache modules like mod_php and mod_perl
screenshot

(this is a screenshot of wapache running phpmyadmin)
How to turn your php script into an executable
1) copy all of your scripts/files into the htdocs directory (make sure that the main file is called index.php)
2) launch bin/wapache.exe
3) you will now see your php script in the application that is running
There is also many options that allow you to configure the app in many different ways. This can be found on line 100 of conf/default.wcf (documentation for this config file can be found here):
HorizontalAlign Center
VerticalAlign Middle
Height 60%
Width 60%
3DBorder Off
IconPath "../icons/lightbulb.ico"
</StandardWindow>
This could be used for a demo/trial of a web application. A windows installer could also be used (NSIS works well and is free) to create a fully installable, desktop application.
Since this only relies on the apache web server, it’s also possible to use this with any type of supported scripts.
Download
The latest version of Wapache can be found here
May 13, 2009 3 Comments
Is this a windows killer?
ReactOS is a free and open-sourced operating system based on the Windows NT architecture, providing support for existing applications and drivers, and an alternative to the current dominant consumer operating system. The interesting part about this open source project is that unlike applications like Wine, it is an operating system completely re-written from the ground up, with windows binary compatibility in mind.
History
ReactOS has been written from scratch since 1996, a rock solid NT re-implementation, and therefore a reliable and robust operating system for tasks ranging from embedded micro computer to personal computer, workstations to server cluster, mainframes and super computers. It incorporates many design decisions from other operating system families like UNIX, VMS, OS/2 and of course NT and is meant as ‘the’ new platform that serves all.
Screenshots
The following are screenshots of reactOS running some popular windows apps.

(Winrar)

(Quake 1)

(Unreal Tournament)
Installation
I decided to give reactOS a shot. I didn’t want to re-partition my harddrive or format, so I downloaded the virtual machine version that you can run within windows (it includes the reactOS image and virtual machine software to run it).
Installation (if you can call it that) was seamless. I just downloaded the zip file, extracted it and ran boot.exe. Within a few seconds, it booted into the OS on the virtual machine.

Looking around, the gui needs some work. There are also a few useful applications pre-installed: remote desktop, solitare, minesweeper (what OS is complete without minesweeper), and reactOS explorer (I was able to get onto the Internet through an automatic download of the Mozilla ActiveX plugin).
I was able to install the latest version of Firefox, which installed without any issues. However, when I tried to launch it, I got some strange font/graphic issues.

ReactOS has a lot of promise. Once it is out of an alpha/pre-beta state and supports more hardware, it could be serious competition for Microsoft.
You can try it yourself by going to the reactOS website: Here
If you are having any speed issues, you can install an accelerator for the virtual machine here (Under the section “Accelerators”)
Another good tool to install is here. It allows you to mount the virtual hard disk in your Windows system.
April 15, 2009 No Comments
5 cool things you can do with windows and php
Many PHP examples out there are designed for a linux/unix operating system. I am going to give some examples of some interesting functionality that only works with php running in a windows environment (IIS or apache).
1) Eject the CD-ROM
$mp = new COM("WMPlayer.OCX");
//ejects the first cd-rom on the drive list
$mp->cdromcollection->item(0)->eject();
2) Read and write from/to the registry
{
$WshShell = new COM("WScript.Shell");
$registry = "HKEY_LOCAL_MACHINE\SOFTWARE\\" . $folder . "\\" . $key;
$result = $WshShell->RegRead($registry);
return($result);
}
$key = registry_read("RegisteredApplications","Firefox");
parameters:
- Folder name – (key path past HKEY_LOCAL_MACHINE\SOFTWARE\\)
- key – the key name to read from
{
$WshShell = new COM("WScript.Shell");
$registry = "HKEY_LOCAL_MACHINE\SOFTWARE\\" . $folder . "\\" . $key;
$result = $WshShell->RegRead($registry);
$result = $WshShell->RegWrite($registry,$value, $type);
return($result);
}
parameters:
- Folder name – (key path past HKEY_LOCAL_MACHINE\SOFTWARE\\)
- key – the key name to write to
- value – value that will be written to the key
- type – key type (default: REG_SZ)
3) register and un-register phpscripts as a windows service
# registering a service
win32_create_service(array(
’service’ => ‘myservice’, # the name of your service
‘display’ => ’sample dummy PHP service’, # description
‘params’ => ‘c:\path\to\script.php run’, # path to the script and parameters
));
# un-registering a service
win32_delete_service(’myservice’);
# code run as a service
win32_start_service_ctrl_dispatcher('myservice');
while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) {
# write script here
# as a general rule, keep it below 30 seconds through each loop iteration
}
}
This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:
- Download the main library (it’s included in the main PECL extension download from php.net)
- extract php_win32service.dll to your ext directory (where your php extension .dlls are located)
- add the following line to your php.ini: extension=php_win32service.dll
4) print pages/data
#this is an example function that will format a host/printer name, for printing to shared printers over the network
function getPrinter($host,$SharedPrinterName) {
return “\\\\”.$host.”\\”.$SharedPrinterName;
}
#this opens the printer
$handle = printer_open(getPrinter(”my computer 2″,”my printer”));
An extensive list of functions for printing can be found here
#this is possible in *nix as well. Here is some example code
function lpr($string,$printer) {
$prn=(isset($printer) && strlen($printer))?”$printer”:C_DEFAULTPRN ;
$CMDLINE=”lpr -P $printer “;
$pipe=popen(”$CMDLINE” , ‘w’ );
if (!$pipe) {print “pipe failed.”; return “”; }
fputs($pipe,$string);
pclose($pipe);
}
This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:
- Download the main library (it’s included in the main PECL extension download from php.net)
- extract php_printer.dll to your ext directory (where your php extension .dlls are located)
- add the following line to your php.ini: extension=php_printer.dll
5) List the current system processes
# list all the current processes running on the system
print_r(win32_ps_list_procs());
other related commands:
# Retrieves statistics about the global memory utilization
print_r(win32_ps_stat_mem());
# Retrieves statistics about the process with the process id pid (if no process id is given, the current process will be used)
print_r(win32_ps_stat_proc(int processid));
This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:
- Download the main library (it’s included in the main PECL extension download from php.net)
- extract php_win32ps.dll to your ext directory (where your php extension .dlls are located)
- add the following line to your php.ini: extension=php_win32ps.dll
March 31, 2009 14 Comments