Script to Remotely Reset Cisco 7900 Series Phones through Telnet
Mon, Nov 16, 2009I used AutoIT to create the following script to reset my Cisco 7940 IP Phones. It could be modified to script almost any telnet commands. It uses a file called “phones.txt” with a list of IP addresses (one on each line). Make sure you have that in the same directory.
Let me know if there is an interest in a compiled EXE version of this script that prompts for the password and I can put that together here.
The script follows:
<br />
$phonestxt = FileOpen("phones.txt",0)<br />
$couldntreset = "I couldn't reset the following phones:"<br />
$failedonce = 0<br />
$endoffile = 0
While 1<br />
$phonesIP = FileReadLine($phonestxt)<br />
if @error = 1 Then<br />
MsgBox(0,"Error!","Couldn't read phones.txt")<br />
Exit<br />
ElseIf @error = -1 Then<br />
$endoffile = 1<br />
EndIf
<br />
If $phonesIP <> "" then<br />
TCPStartup()<br />
Dim $IPtoTelnetTo = $phonesIP<br />
Dim $port = "23"<br />
Dim $ConnectedSocket = -1<br />
$ConnectedSocket = TCPConnect($IPtoTelnetTo, $port)<br />
If $ConnectedSocket = -1 Then<br />
$failedonce = 1<br />
$couldntreset = $couldntreset & " " & $phonesIP & ","<br />
EndIf
Sleep('200')<br />
TCPSend($ConnectedSocket, "PASSWORD" & @CRLF)<br />
Sleep('200')<br />
TCPSend($ConnectedSocket, "reset" & @CRLF)<br />
TCPCloseSocket($ConnectedSocket)<br />
TCPShutdown()<br />
EndIf
<br />
If $endoffile = 1 Then<br />
If $failedonce = 1 then<br />
MsgBox(0,"Error!",$couldntreset)<br />
Else<br />
MsgBox(0,"Complete","All phones have been reset")<br />
EndIf<br />
Exit<br />
EndIf
WEnd