Remote Reboots with ColdFusion MX
Tutorial Title: Remote Reboots with ColdFusion MX

Summary:
This tutorial will tell you how to reboot your server without even logging in.

Tutorial:
I was faced with a dilemma this weekend. I had a crash on my cable connection as I was connected to my dedicated server using Remote Desktop Connection. This meant that that when I went to log back in to the server, I couldn’t as the maximum number of remote sessions had been reached.

So. No access to the OS to reboot. It’s a Sunday so the support teams couldn’t reboot the server for me. Ring the data centre? No chance. What to do? After panicking for about 15 minutes and a quick chat with Pablo on MSN, where this idea spawned from, I wrote a very simple script to reboot the server.

To run this script you need to have CFEXECUTE enabled for your domain which if you own the server is not really an issue!!!

There is a command line instruction called tsshutdn.exe on Windows machines and servers. This command can be used for a number of things including rebooting the server. Here’s the command with the available parameters:

TSSHUTDN [wait_time] [/SERVER:servername] [/REBOOT] [/POWERDOWN]
[/DELAY:logoffdelay] [/V]

wait_time - Seconds to wait after user notification before terminating all user sessions (default is 60).

/SERVER:servername The server to shut down (default is current).
/REBOOT Reboot the server after user sessions are terminated.
/POWERDOWN The server will prepare for powering off.
/DELAY:logoffdelay Seconds to wait after logging off all connected
sessions (default is 30).
/V Display information about actions being performed.

All I wanted to do was reboot the server so in notepad I wrote the following:

Tsshutdn.exe 0 /reboot /delay:0

Save this file as reboot.bat. A bat file is simply a set of instructions normally run from the command prompt. The above instruction translates to “Reboot the server with 0 seconds delay”

Now we just needed to execute this command on the server. Upload you reboot.bat file to your server.

Create a new CFML file and call it reboot.cfm or whatever. Within the body tags for that file add the lines:

<cfexecute name = "c:\inetpub\yoursite\wwwroot\reboot.bat" timeout = "20">
</cfexecute>

You will need to replace "c:\inetpub\yoursite\wwwroot\reboot.bat" with the physical path to the BAT file on your web server.
Now simply use your browser and go to http://www.yourdomain.com/reboot.cfm and the server will reboot.

This is obviously quite a drastic measure and should only be done in extreme circumstances where a reboot is the only answer and I take NO RESPONSIBILITY WHATSOEVER IF YOU BREAK YOUR SERVER!

Submitted by: Phil Williams
Email: support@openmindhosting.com
Site: http://www.openmindhosting.com



All ColdFusion Tutorials By Author: Phil Williams
  • Create and email ZIP files on the fly!
    This tutorial will allow you to zip up a file or files on your server and email them to you. The whole tutorial runs to less than 20 lines of code!
    Author: Phil Williams
    Views: 8,206
    Posted Date: Thursday, October 28, 2004
  • Currency Conversion using Web Services
    A very simple currency convertor that uses the latest exchange rates through the available Web Service
    Author: Phil Williams
    Views: 11,120
    Posted Date: Wednesday, April 21, 2004
  • Remote Reboots with ColdFusion MX
    This tutorial will tell you how to reboot your server without even logging in.
    Author: Phil Williams
    Views: 6,631
    Posted Date: Sunday, July 18, 2004
  • SE Friendly URL's
    Get the search engines to really dig deep into your site by replacing the ? and & in your dynamic URL's with /. Tricks the SE bot into thinking it's a regular folder and eats up your content!
    Author: Phil Williams
    Views: 19,988
    Posted Date: Wednesday, February 12, 2003