Restart your Windows computer remotely using PHP

Sometimes, the programs you use to connect to your PC (e.g. TeamViewer) might fail and your computer might need a reboot to start them again. If your Web server running PHP is still up and running and you have a way to create a file on it (some php file editor, ftp etc.).

This is what it needs to contain:

<?php
exec('shutdown -f -t 0 -r');
?>

More details about the shutdown command you will find below:

ParameterFunction
-sShuts down the comptuer.
-rReboots the computer.
-fForce-close all running applications.
-m \\ComputerSpecifies a specific computer on the network that you want to shut down or reboot. Absent this parameter, the command affects only the local PC on which it is run.
-t xxSets a delay (xx seconds) before the specified operation commences.
-c “message”Add your own text inside the quotations to provide remote users with a message about why and when their PC will shut down or reboot.
/aAborts a shutdown or restart if used during the (-t) delay period.
/hHibernates the computer.
/?Displays the full help document with all commands.