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:

Parameter Function
-s Shuts down the comptuer.
-r Reboots the computer.
-f Force-close all running applications.
-m \\Computer Specifies 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 xx Sets 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.
/a Aborts a shutdown or restart if used during the (-t) delay period.
/h Hibernates the computer.
/? Displays the full help document with all commands.