Reboot or execute arbitrary code on a remote computer by mail

Short description:

Reboot a remote computer by simply activating a new rule in Microsoft Outlook that triggers the execution of an application “*.exe”.

Long description:

Sometimes we connect to remote computer, for example from home to the work office pc, or vice versa from the pc in office to the pc at home, but sometimes something go wrong, the Remote Desktop doesn’t connect for various reasons, but the most recurring is that the remote computer has some Windows updates hanging, or requires a reboot to finish some task. The best solution that solve these issues is effectively a reboot of the remote computer. Various steps are involved both on the remote computer and on your computer:

On the remote computer:

  • prepare a Windows batch file with this line, saving it i.e. c:\temp\My_Reboot.bat

shutdown -r -f

this line can be replaced with all the code you want. You must test it before the final utilization. In this example, Windows will display an alert that the system will reboot after a minute; you can cancel a test reboot with shutdown -a

  • go to this page and download Bat To Exe Converter, install it, and use it with the default settings, to convert My_Reboot.bat to My_Reboot.exe, saving the output in c:\temp\My_Reboot.exe

Now,

  • open Microsoft Outlook (or other advanced mail client) and create a new Rule from the ribbon buttons; you can follow this post but choosing the Advanced options… button
    • Step 1: Select conditions
      You can set On “On this computer only”, “with specific words in the subject or body” specifying in the “Step 2” window below some uncommon words (i.e. something like “pleaserebootthiscomputer”, however some phrase that cannot be common otherwise this trigger can be activated by other mail too 🤣).
      Select “from people or public group” specifying in the “Step 2” window below only your email from which you are sending the command
    • Step 1: Select actions
      Set On “stop processing more rules”, “start application” 😲 omg this option does not exist!!!! Follow this page to activate this option 😅
      In the “Step 2” window below select My_Reboot.exe in c:\temp saved before
  • Click finish to terminate this setting.

On another computer (or from a smartphone):

  • Send an email from the address specified here and with subject specified here

Et voilà

Leave a Reply

Your email address will not be published. Required fields are marked *