In the last couple of weeks, I have been working with a customer who has had a number of issues with their broadband connection thanks to the incompetency of the ISP.  The long and short of it, is that we need to reboot the router daily, generally late at night so that it continues to work the next day.

So the challenge was how do I get the router rebooted, especially late at night.?   The answer was simple, write (or find and use) a script to remotely login and reboot the router.

To do this, you will need to create a batch file, with the script as below. Change the <Password> and <IPADDRESS> tags to be your own without the <> keys.

@ECHO OFF
:: Create SendKeys script
ECHO.set sh=WScript.CreateObject("WScript.Shell")>_TEMP.VBS
:: Start Telnet session
ECHO.sh.run("telnet.exe <IPADDRESS>")>>_TEMP.VBS
:: Wait 1 second for telnet session to start
ECHO.WScript.Sleep 1000 >>_TEMP.VBS
:: Send password
ECHO.sh.SendKeys "<Password>~" >>_TEMP.VBS  
<— Note that there is a ~ after the password, this is needed as its the key for ENTER

:: Insert your commands here followed by ~ for <enter>
ECHO.sh.SendKeys "sys reboot~" >>_TEMP.VBS

:: Run the script to send keys to Telnet window
cscript//nologo _TEMP.VBS

:: Clear away workfile
DEL _TEMP.VBS

Save the file as a batch file such as “Reboot Router.BAT” to the machine that you want to run it from . Once you have created the batch file, you can run it with a remote management tool such as CentraStage, or GFI MAX or alternatively run it using the Task Scheduler.

 

TELNET

In order to use the script above, you require TELNET.EXE to be installed on the system that you run it from. Windows 7,  and Windows 2008 do not include the telnet program.. or at least not by default. You can however turn it on :-

 

Click Start Start Button 

Then click on Control Panel and select “Uninstall a Program” under the Programs heading.

Programs 

Then click on image  on the Left hand menu.

At this point you will be presented with the Features window, and you can select Telnet Client and then press OK.

Features

Telnet will now be installed to the %SYSTEMROOT% folder meaning that you should be able to just run telnet.exe from anywhere and it should work ok. The above script will now run ok.

There are a number of things you can do with the script above,  such as changing the Router IP address and various other things, for a full list of the telnet commands for the Draytek Routers, you can download the Telnet command guide from  here.

Authored by, Chris Timm  Managing Director at TCG Computer Services Limited – providing  IT Support in Basingstoke, IT Support in Reading and IT Support in Newberry  Find out more from Chris at  Twitter and linkedin.

Bookmark and Share