Jump to content

running a .exe server side with html


dzhax

Recommended Posts

I host a game for someone on my pc. I was wondering if there is a way for you to click a link on a website and it runs a .exe on my pc to restart the game?I host this website on this pc also so the files are in the same folder as the webpage.

Link to comment
Share on other sites

If you mean run the executable on your server (which also happens to be your personal computer), then you could use something like PHP's exec().If you mean run it on the client's PC, then no.

Link to comment
Share on other sites

can you give sample code please im not completly sure what you mean.say i am at someone elses house. i can go on my site, click a link, and it runs the restarter on my home server. is this what that code will do?

Link to comment
Share on other sites

Yes. Does your server have PHP enabled? If so, something like this will work.

<?phpexec("C:\path\to\file\program.exe");echo "The program has been run.";?>

The argument for exec() is in the same format as you would type it into the command line.Read: http://static.php.net/manual/en/book.exec.php

Link to comment
Share on other sites

Umm... you have to use a server-side language - one that your server supports.If your server does support PHP:Did you name the file with a .php extension?Does your command work if you type it in the command line?Could you paste the code you tried here?

Link to comment
Share on other sites

yea it is saved as a .php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><meta http-equiv="refresh" content="5;url=manager-control.php" /><title>Performing Requested Action</title><style type="text/css">.style1 {	text-align: center;}</style></head><body style="color: #FFFFFF; background-color: #000000; background-image: url('images/background1.JPG')"><?phpexec("C:\Documents and Settings\Lou\Desktop\Bashscape - New source\shut.exe");echo "The server has been restarted.";?><p class="style1">Performing Requested Action...<br />You will be redirected after the action completes.</p><?php include('footer.html'); ?></body></html>

[EDIT] Also since u seem to know php i have a post in the php section. no one has posted on it yet. http://w3schools.invisionzone.com/index.php?showtopic=21797

Link to comment
Share on other sites

You didn't test that command on the command line did you :)The DOS CL accepts folders of up to 8 characters, if your name is longer you have to reference it as longna~1, longna~2, etc. E.g.

C:\Docume~1\Lou\Desktop\Bashsc~1\shut.exe

Link to comment
Share on other sites

sorry for being such a pain. but i still cant get it to work right. i moved the game to folder C:\server\ so the folders arent so long. my zonealarm picked up that the shut.exe is trying to run. i allowed it. but nothing happens.

<?phpexec("c:\server\shut.exe");echo "The server has been restarted.";?>

Link to comment
Share on other sites

Did you try running that from the command line?Also, try something simple, like shutting the computer down. Does that work?

Link to comment
Share on other sites

That is the way to do it in PHP, and if it doesn't work then there is something wrong with your code :). You could use another server-side language but the technique is similar.When you click on the link to load the page with the exec() on it, what do you see?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...