Here is my code so far.
<html>
<head>
<script language="JavaScript">
function java(){
process process = new ProcessBuilder("Pathtomyprogram").start();
}
</script>
</head>
<form name="Test">
<input type="button" value="Test" onClick="java()">
</form>
</body>
</html>
The problems happen when I go in my web browser and click the button that I created and it doesn't start the program I specified on the host computer. I may be making a completely obvious mistake as I have been stitching together code from multiple sources. So basically, how can I start a program by opening my website (on which the javascript is hosted) on say my phone and after clicking the button it opens a program on the host computer?
If this isn't possible and I've been a complete moron, please let me know!
This javascript is being hosted on Apache 2.2 on a Windows XP PC if that was necessary to know.
Edit: Wow, I was really dumb in that question from awhile ago. Ok, so I realize my question was not formed well AT all. Here is how to do it instead.
My solution was found in PHP and is very sloppy and should NOT be used at all, but here it is for anyone who needed to do what I was doing.
Ok, so the thing is, as many people have pointed out below, it is just too risky to allow programs to be started on a server from a client. There is NO pure way around this, but there's a sneaky, impractical way.
<?php
function play() {
$myfile = fopen("start.txt", "w") or die("Unable to open file!");
}
?>
What this does is write "w" to a "start.txt" file on the server. There is also a batch program (doesn't have to be batch obviously) running on the server looking to see if "start.txt" exists. If it does, it runs the thing I wanted it to, then deletes "start.txt" so as to reset it for the next time.
Here's the "batch.bat" code for anyone interested, of course.
@echo off
:home
if exist start.txt goto next
goto home
:next
rem Code you want to be executed goes here.
cls
del start.txt
goto home
But really, unless this is something you or a small selection of friends that you trust will use, never do this. I am much wiser and know more about javascript and web programming in general now, and this, even I can recognise, is a horrible fix. Thanks!