dzhax Posted October 4, 2008 Share Posted October 4, 2008 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 More sharing options...
Synook Posted October 4, 2008 Share Posted October 4, 2008 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 More sharing options...
dzhax Posted October 4, 2008 Author Share Posted October 4, 2008 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 More sharing options...
Synook Posted October 4, 2008 Share Posted October 4, 2008 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 More sharing options...
dzhax Posted October 5, 2008 Author Share Posted October 5, 2008 that didnt work. any otherway? Link to comment Share on other sites More sharing options...
Synook Posted October 5, 2008 Share Posted October 5, 2008 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 More sharing options...
dzhax Posted October 5, 2008 Author Share Posted October 5, 2008 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 More sharing options...
Synook Posted October 5, 2008 Share Posted October 5, 2008 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 More sharing options...
dzhax Posted October 5, 2008 Author Share Posted October 5, 2008 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 More sharing options...
redwall_hp Posted October 6, 2008 Share Posted October 6, 2008 You could try using system() instead of exec(): <?phpsystem("c:\server\shut.exe");echo "The server has been restarted.";?> Link to comment Share on other sites More sharing options...
dzhax Posted October 6, 2008 Author Share Posted October 6, 2008 nope still not working... Link to comment Share on other sites More sharing options...
Synook Posted October 6, 2008 Share Posted October 6, 2008 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 More sharing options...
dzhax Posted October 6, 2008 Author Share Posted October 6, 2008 it works on command line. but now the page will not load, that runs the php script then redirects back. Link to comment Share on other sites More sharing options...
dzhax Posted October 8, 2008 Author Share Posted October 8, 2008 does anyone else know a different way of doing this? the php doesnt seem to work. Link to comment Share on other sites More sharing options...
Synook Posted October 9, 2008 Share Posted October 9, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.