Tuesday, June 29, 2010

VBScript to Telnet and Perform GET Operation

I have a web application server that I have to restart regularly. When I restart this service, I want to telnet into the box, perform a GET / request and ensure that HTML is returned. While this script seems simple, it provides me with a great peace of mind when run in combination with some other scripts. It lets me know the system is up and functioning after the restart.

Option Explicit

Dim objShell

Set objShell = CreateObject("WScript.Shell")

objShell.run "%SYSTEMROOT%\System32\telnet.exe localhost 443"

wscript.sleep 1*1000

objShell.SendKeys "GET /{ENTER}"

Wscript.Sleep 2*1000

objShell.SendKeys "{ENTER}"

Set objShell = Nothing

wscript.Quit 0

1 comment:

Umesh said...

This was so useful..thanks for sharing. I also have a blog: http://configmgr-wsus.blogspot.com/