Hello group, the following requirement to programatically control
device/s via VBScript may interest many experiencing similar
issues....

Background:
Cable modem - connected to ISP. Router - connected between Cable Modem
& LAN.

Problem:
ISP continually has network issues and requires End-User to restart
Cable modem and then the Router. Although inconvenient, this is OK if
End User is on site at the time.

Question for Group;
Taking into account the above information, can I perform the following
programatically with VBScript:

1. Connect to the cable modem's web page and select the "Reboot"
button from a LAN W2K3 PC/server?

2. Connect to the Router's web page, supply credentials and select the
"Restart" button from a LAN W2K3 PC/server?

Note: I have a scheduled job executing a VBScript that monitors the
Cable connection to the ISP. When this script detects that the
connection is down, I want the proposed "Restart" Script to run. This
script must be able to be run without having an End User log on to run
the script.

This may be asking too much, any Ideas greatly appreciated......

Cheers

Re: Start and manipulate a web page via vbscript remotely by Don

Don
Tue Mar 15 00:02:55 CST 2005

"Johann Koelmeyer" <jfcp37@hotmail.com> wrote in message
news:d450fb24.0503142039.d824390@posting.google.com...
> Hello group, the following requirement to programatically control
> device/s via VBScript may interest many experiencing similar
> issues....
>
> Background:
> Cable modem - connected to ISP. Router - connected between Cable Modem
> & LAN.
>
> Problem:
> ISP continually has network issues and requires End-User to restart
> Cable modem and then the Router. Although inconvenient, this is OK if
> End User is on site at the time.
>
> Question for Group;
> Taking into account the above information, can I perform the following
> programatically with VBScript:
>
> 1. Connect to the cable modem's web page and select the "Reboot"
> button from a LAN W2K3 PC/server?
>
> 2. Connect to the Router's web page, supply credentials and select the
> "Restart" button from a LAN W2K3 PC/server?
>
> Note: I have a scheduled job executing a VBScript that monitors the
> Cable connection to the ISP. When this script detects that the
> connection is down, I want the proposed "Restart" Script to run. This
> script must be able to be run without having an End User log on to run
> the script.
>
> This may be asking too much, any Ideas greatly appreciated......
>
> Cheers

I wrote this script for a billion 7500G router, to monitor connection and
issue reboot command to router.
If the router you are using has telnet access then this should work will
little changes, you should get the gist from the script.this script also
emails me if a problem, it may be of use to you.
''''''''''''''''''
'**************************************************************
' Name: Batch Telnet Script, for Billion 7500G Router
'To check for internet access and restart router if fails
'Written 6 March 2005 by Don Grover Email: dgrover@assoft.com.au
'**************************************************************
Option Explicit
Dim sRetVal
Const sRouteruserName = "USERNAME" 'The router
login user name
Const sRouterPassword = "PASSWORD" 'The router
login password
Const sRouterIpAddress = "192.168.1.254" 'The IP
Address of Router
Const lngDelay = 1000
'Delay in ms between sending commands
Const sTestFile = "http://ninemsn.com.au/img/arr_news.gif" 'File located on
internet to test internet connectivity
Const myMailServer = "MAILSERVERNAME"
'The IP or Name of Your Mail Server
Const myEmailPort = 25
'The Outgoing Email Port
Const sEmailAddFrom = "MY@EMAIL.ADDRESS" 'Who this email is
from
Const sEmailAddToo = "MY@EMAIL.ADDRESS" 'Who this email is to

sRetVal = CheckForRestart
ShowMessage "Checking Router", sRetVal


Function CheckForRestart()
'***************************************************************
'Check if the router is available if True then check for Internet
'connection if true exit else if false call restartrouter
'***************************************************************
If fetch("http://" & sRouterIpAddress & "/customized/logo.gif") = True Then

If fetch(sTestFile) = True Then
CheckForRestart = False
Else
RestartRouter ' We have no connection
so restart router
CheckForRestart = True
SendEmail "Router Restarted at : " & FormatDateTime(Date,1) & "
" & FormatDateTime(Time,3),"Router I.P.#: " & sRouterIpAddress & "
Restarted"
End If
Else
SendEmail "Router Unreachable at : " & FormatDateTime(Date,1) & " "
& FormatDateTime(Time,3),"Router I.P.#: " & sRouterIpAddress & "
Unreachable"
CheckForRestart = False
End If


End Function

Function fetch(url)
'*************************************
' Check if the passed in url is available
'*************************************
On Error Resume Next
Err.Clear
Dim b
ShowMessage "Checking " & url, "Check Connection"
With CreateObject("Microsoft.XMLHTTP")
.Open "GET", url, False
.Send
b = .ResponseBody
If Err.Number <> 0 Or .Status <> 200 Then
fetch = False
Exit Function
Else
fetch = True
Exit Function
End If
End With
End Function


Sub RestartRouter()
'*************************************
' Connect with Telnet and Restart Router
'*************************************
Dim objShell
On Error Resume Next
ShowMessage "Re-Starting Router", "Router Restart"
'Create the shell object
Set objShell = CreateObject("WScript.Shell")
'Start up command prompt
objShell.run "cmd.exe"
WScript.Sleep lngDelay
'Send keys to active window; change the ip address as needed.
objShell.SendKeys "telnet " & sRouterIpAddress
'Emulate the enter key
objShell.SendKeys ("{Enter}")
WScript.Sleep lngDelay
'write the user name to the cmd window
objShell.SendKeys sRouteruserName
objShell.SendKeys ("{Enter}")
WScript.Sleep lngDelay
'write the password to the cmd window
objShell.SendKeys sRouterPassword
objShell.SendKeys ("{Enter}")
WScript.Sleep lngDelay
'write the restart sequence to the cmd window
objShell.SendKeys "system restart"
objShell.SendKeys ("{Enter}")
WScript.Sleep lngDelay
'Exit the program script
objShell.SendKeys "exit"
objShell.SendKeys ("{Enter}")
objShell.SendKeys "% "
Set objShell = Nothing
On Error GoTo 0
End Sub

Sub ShowMessage(TheMessage,TheHeading)
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Popup TheMessage & "...", 2, TheHeading & "", 0 + 64
Set WshShell = Nothing
End Sub



Sub SendEmail(TheBodyText,TheSubJectText)

'******************************************************
'*** Send the message Using CDOSYS Win2k & Win2003 ****
'******************************************************
On Error Resume Next
Dim sch, cdoConfig, cdoMessage, sError
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(sch & "sendusing") = 2
cdoConfig.Fields.Item(sch & "smtpserverport") = myEmailPort
cdoConfig.Fields.Item(sch & "smtpserver") = myMailServer
cdoConfig.Fields.Update
Set cdoMessage = CreateObject("CDO.Message")
Set cdoMessage.Configuration = cdoConfig
cdoMessage.From = sEmailAddFrom
cdoMessage.To = sEmailAddToo
cdoMessage.CC = ""
cdoMessage.BCC = ""
cdoMessage.Subject = TheSubJectText
cdoMessage.TextBody = TheBodyText
'
cdoMessage.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").value
= 1 ' use clear text authenticate
'
cdoMessage.item("http://schemas.microsoft.com/cdo/configuration/sendpassword").value
="mypassword"
'
cdoMessage.item("http://schemas.microsoft.com/cdo/configuration/sendusername").value
="yourusername"
cdoMessage.Fields.Item("urn:schemas:mailheader:X-MSMail-Priority") =
"High"
cdoMessage.Fields.Item("urn:schemas:mailheader:X-Priority") = 2
cdoMessage.Fields.Item("urn:schemas:mailheader:Keywords") = "ROUTER
SUPPORT"
cdoMessage.Fields.Item("urn:schemas:mailheader:Sensitivity") =
"Company-Confidential"
cdoMessage.Fields.Item("urn:schemas:mailheader:X-Message-Flag") = "Do
not Forward"
'cdoMessage.Fields.Item("urn:schemas:mailheader:Disposition-Notification-To")
= "Don Grover <support@assoft.com.au>"
cdoMessage.Fields.Update
cdoMessage.Send
Set cdoMessage = Nothing
Set cdoConfig = Nothing
If Err.Number <> 0 Then
sErrorDesc = Err.Description
sErrorNum = Err.Number
ShowMessage sErrorDesc & VBCrLf & sErrorNum, "Email Problem"
Else
ShowMessage "Email sent to " & sEmailAddToo, "Email Sent"
End If
On Error GoTo 0
End Sub


''''''''''''''''''''
Regards
Don Grover





Re: Start and manipulate a web page via vbscript remotely by jfcp37

jfcp37
Wed Mar 16 19:40:25 CST 2005

Thanks Don,

The cable modem & router do not allow telnet, that is why I wanted to
use the web page.

Thanks for your response....

Johann