Hi! I am a newbie with programming. I have two Windows 2003 servers. Both
servers have the same service that only one can run at one time. I would
like to create a script that would check the network status of Server A using
ping.exe. If the ping fail on Server A, Server B will start the service. I
figure out how to write teh ping but not sure how to incorporate the other
step.
Set objShell = CreateObject("WScript.Shell")

Set objWshScriptExec = objShell.Exec("ping 10.0.0.1 -t")

Set objStdOut = objWshScriptExec.StdOut

Do Until objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
If Len(strLine) > 2 Then
WScript.Echo Now & " -- " & strLine
Else
Wscript.Echo strLine
End If
Loop

Re: ping and start a service on remote server by Owen

Owen
Fri Jan 26 11:20:20 CST 2007

> Hi! I am a newbie with programming. I have two Windows 2003 servers. Both
> servers have the same service that only one can run at one time. I would
> like to create a script that would check the network status of Server A using
> ping.exe. If the ping fail on Server A, Server B will start the service. I
> figure out how to write teh ping but not sure how to incorporate the other
> step.
> Set objShell = CreateObject("WScript.Shell")
>
> Set objWshScriptExec = objShell.Exec("ping 10.0.0.1 -t")
>
> Set objStdOut = objWshScriptExec.StdOut
>
> Do Until objStdOut.AtEndOfStream
> strLine = objStdOut.ReadLine
> If Len(strLine) > 2 Then
> WScript.Echo Now & " -- " & strLine
> Else
> Wscript.Echo strLine
> End If
> Loop

Check out ADSI, which has a lot of collections designed for managing
servers. I think that'll work better for you than trying to use ping.


There's a new utility to download here:

http://www.microsoft.com/technet/scriptcenter/tools/admatic.mspx


RE: ping and start a service on remote server by johnisccp

johnisccp
Fri Jan 26 15:41:04 CST 2007

I have a VB script to run the ping and batch file to start the service. The
code below is my ping command. I would like to call the batch file inside
the ping VB script only if the ping requested time out. Any help would be
appreciative

Thanks

"johnisccp" wrote:

> Hi! I am a newbie with programming. I have two Windows 2003 servers. Both
> servers have the same service that only one can run at one time. I would
> like to create a script that would check the network status of Server A using
> ping.exe. If the ping fail on Server A, Server B will start the service. I
> figure out how to write teh ping but not sure how to incorporate the other
> step.
> Set objShell = CreateObject("WScript.Shell")
>
> Set objWshScriptExec = objShell.Exec("ping 10.0.0.1 -t")
>
> Set objStdOut = objWshScriptExec.StdOut
>
> Do Until objStdOut.AtEndOfStream
> strLine = objStdOut.ReadLine
> If Len(strLine) > 2 Then
> WScript.Echo Now & " -- " & strLine
> Else
> Wscript.Echo strLine
> End If
> Loop

Re: ping and start a service on remote server by E

E
Fri Jan 26 20:09:25 CST 2007

Be careful using ping to check the status of a server. First, a server could be down (emails not
being processed [if an email server]) and still respond to a ping. Also, on a busy network pings
traffic can be ignored in order to process higher priority traffic (rare). You might want to check
service status instead/as well.

johnisccp wrote:
> Hi! I am a newbie with programming. I have two Windows 2003 servers. Both
> servers have the same service that only one can run at one time. I would
> like to create a script that would check the network status of Server A using
> ping.exe. If the ping fail on Server A, Server B will start the service. I
> figure out how to write teh ping but not sure how to incorporate the other
> step.
<SNIP>

Re: ping and start a service on remote server by Owen

Owen
Tue Jan 30 13:13:08 CST 2007

On Jan 26, 1:41 pm, johnisccp <johnis...@discussions.microsoft.com>
wrote:
> I have a VB script to run the ping and batch file to start the service. The
> code below is my ping command. I would like to call the batch file inside
> the ping VB script only if the ping requested time out. Any help would be
> appreciative
>
> Thanks
>
>
>
> "johnisccp" wrote:
> > Hi! I am a newbie with programming. I have two Windows 2003 servers. Both
> > servers have the same service that only one can run at one time. I would
> > like to create a script that would check the network status of Server A using
> > ping.exe. If the ping fail on Server A, Server B will start the service. I
> > figure out how to write teh ping but not sure how to incorporate the other
> > step.
> > Set objShell = CreateObject("WScript.Shell")
>
> > Set objWshScriptExec = objShell.Exec("ping 10.0.0.1 -t")
>
> > Set objStdOut = objWshScriptExec.StdOut
>
> > Do Until objStdOut.AtEndOfStream
> > strLine = objStdOut.ReadLine
> > If Len(strLine) > 2 Then
> > WScript.Echo Now & " -- " & strLine
> > Else
> > Wscript.Echo strLine
> > End If
> > Loop- Hide quoted text -
>
> - Show quoted text -

Check out ADSI, which has a lot of collections designed for managing
servers. I think that'll work better for you than trying to use
ping.

There's a new utility to download here:


http://www.microsoft.com/technet/scriptcenter/tools/admatic.mspx