I researched how to do it and everyone was saying the Adobe Air did not have this functionality by default. Sure there are "add-ons" that could do it but I was lazy and am not too sure about compiling or paying for anything. I already have a web server installed on my local machine and I knew PHP had the ability to execute commands so I embarked on my journey with that. Took me a long time to figure this out.

Enough with the background let's start actually doing something. I have Apache 2.2.11 with PHP 5.3.0. I did not install these using an all-in-one installer like XAMPP. I installed it all separately so I do not know if it works using the all-in-one solution. This should also work on earlier versions but I have not tested with them. I have Adobe Air 1.5.2 installed and am using Aptana 1.5 to program all files.

First let's configure the server. This is assuming you have Apache and PHP setup already.

1) During Apache installation you could have installed Apache as a service. So go into the services console and Right-Click on Apache2.2 and go to the Properties.
2) Stop the service
3) Change the service to Manual startup
4) Click on the Log on tab and check the checkbox next to "Allow service to interact with the desktop" and click Ok
5) Now we need to create a shortcut in the Startup folder so go to the Start menu and Right-Click on Startup and click Open
6) Now we have Windows Explorer opened to the Startup folder. Right-click anywhere and select create shortcut.
7) This opens a dialog that asks for the location. The executable is under the bin folder under the Apache install folder. Default for me was "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe" and I named mine Apache 2.2
8) Now every time you restart (or click on the shortcut manually), this will start Apache but it opens a command prompt. I used an application called TrayIt and knocks any window to the system tray. It's easy to use so I won't go into detail on that right now.

So now we have Apache starting via a shortcut on every startup and told Windows to allow it to interact with the desktop. Oh and we used TrayIt to hide the Apache window to the system tray.

Now we can create a PHP file and save to your htdocs (or wherever Apache doc root is):


$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("c:\path\to\program.exe", 7, false);

You could test this by opening a browser and pointing to the php file. If it works then we can proceed. If it doesn't, try the server config explained above.

So when creating my Air app I made a button and used an Ext.Ajax.request() to the PHP file that executed the PHP file we just made and it worked.

						waitMsg: "Please wait...",
						url: "http://localhost/app.php",
						success: function(response){
							var result = response.responseText;
						failure: function(response){
			//				alert("failed");
I will go through and edit this post to make it more readable but I wanna play around with this functionality more. Of course if you are making an Air app to distribute this may not be for you unless they have Apache/PHP installed on their machine. Or maybe this will inspire someone to create another easy to use solution.

Other ideas... does Flash or Java have the ability to launch programs? If so, can you make a Flash or Java applet to launch programs and add them in your Air app? Don't know those languages so I have no clue.