Hi

I'm writing a vbscript to shutdown a number of remote computers. After the
script issues the remote shutdown to each computer it opens a Command Prompt
window for each server and runs

ping -t <hostname>

for each server in the list. What I want to be able to do is get the
vbscript to call the Command Prompt and ping the server until a "request
timed out" is returned, where it should then close the Command Prompt window.

Anyone have any ideas ?

Regards

Re: Close Command Prompt upon ping time out ? by Richard

Richard
Sun Sep 09 06:19:18 PDT 2007

Spike Craib wrote:

> I'm writing a vbscript to shutdown a number of remote computers. After the
> script issues the remote shutdown to each computer it opens a Command
> Prompt
> window for each server and runs
>
> ping -t <hostname>
>
> for each server in the list. What I want to be able to do is get the
> vbscript to call the Command Prompt and ping the server until a "request
> timed out" is returned, where it should then close the Command Prompt
> window.
>
> Anyone have any ideas ?

I don't know of an easy way to do this. However, I have 3 example functions
that ping computers in this link:

http://www.rlmueller.net/PingComputers.htm

The functions return True or False. These can be used in a loop to determine
when the remote computer shuts down. For Example:
=======
intCount = 0
blnDown = False
Do Until intCount = 10
If (PingComputer(strComputer, 1, 750) = False) Then
Exit Do
blnDown = True
End If
Wscript.Sleep 5000
intCount = intCount + 1
Loop
========
I use a counter to avoid an infinite loop. The computer is pinged 10 times
with a 5 second pause between each. After the loop if blnDown is True the
machine was successfully shutdown. If blnDown is False machine still
responded after 10 pings.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--



Re: Close Command Prompt upon ping time out ? by Michael

Michael
Sun Sep 09 06:29:20 PDT 2007

On Sun, 9 Sep 2007 01:34:00 -0700, Spike Craib <Spike
Craib@discussions.microsoft.com> wrote in
microsoft.public.scripting.vbscript:

>I'm writing a vbscript to shutdown a number of remote computers. After the
>script issues the remote shutdown to each computer it opens a Command Prompt
>window for each server and runs
>
>ping -t <hostname>
>
>for each server in the list. What I want to be able to do is get the
>vbscript to call the Command Prompt and ping the server until a "request
>timed out" is returned, where it should then close the Command Prompt window.
>
>Anyone have any ideas ?

Here's one: in the command prompt, run PING -n 1 <hostname> instead,
redirect the output to a file, parse that file for "Request timed out.",
loop if not found back to PING.

Alternatively, under the OS here (XP), PING returns an ERRORLEVEL=1
after a timeout. So:
:Again
PING -n1 <hostname> || EXIT
GOTO Again
might work.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"

Re: Close Command Prompt upon ping time out ? by ThatsIT

ThatsIT
Sun Sep 09 08:11:57 PDT 2007


"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
message news:OHkGRQu8HHA.1416@TK2MSFTNGP03.phx.gbl...
> Spike Craib wrote:
>
>> I'm writing a vbscript to shutdown a number of remote computers. After
>> the
>> script issues the remote shutdown to each computer it opens a Command
>> Prompt
>> window for each server and runs
>>
>> ping -t <hostname>
>>
>> for each server in the list. What I want to be able to do is get the
>> vbscript to call the Command Prompt and ping the server until a "request
>> timed out" is returned, where it should then close the Command Prompt
>> window.
>>
>> Anyone have any ideas ?
>
> I don't know of an easy way to do this. However, I have 3 example
> functions that ping computers in this link:
>
> http://www.rlmueller.net/PingComputers.htm
>

Richard I just went to your site, tried running your inventory script. When
I open the excel file it shows that it could not find domain computers. I
assume this is erroring on the ping because after running the script I can
no longer ping computers manually using the same cmd window, I need to open
a new cmd window to ping.

any ideas

PS I think I made a comment about your site some years back, I know you have
great abilities so one wonders why you have such a basic web site I think
made from Visual Studio 6 Themes or maybe Front Page.
I predict your going to say that it does the job and all that, but I think
its time you updated it.

But then at least yours is complete unlike mine that is a ever ongoing work
in progress.




> The functions return True or False. These can be used in a loop to
> determine when the remote computer shuts down. For Example:
> =======
> intCount = 0
> blnDown = False
> Do Until intCount = 10
> If (PingComputer(strComputer, 1, 750) = False) Then
> Exit Do
> blnDown = True
> End If
> Wscript.Sleep 5000
> intCount = intCount + 1
> Loop
> ========
> I use a counter to avoid an infinite loop. The computer is pinged 10 times
> with a 5 second pause between each. After the loop if blnDown is True the
> machine was successfully shutdown. If blnDown is False machine still
> responded after 10 pings.
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>


Re: Close Command Prompt upon ping time out ? by SpikeCraib

SpikeCraib
Sun Sep 09 08:46:02 PDT 2007

Thanks for the advice. I'll give it ago.


"Michael Bednarek" wrote:

> On Sun, 9 Sep 2007 01:34:00 -0700, Spike Craib <Spike
> Craib@discussions.microsoft.com> wrote in
> microsoft.public.scripting.vbscript:
>
> >I'm writing a vbscript to shutdown a number of remote computers. After the
> >script issues the remote shutdown to each computer it opens a Command Prompt
> >window for each server and runs
> >
> >ping -t <hostname>
> >
> >for each server in the list. What I want to be able to do is get the
> >vbscript to call the Command Prompt and ping the server until a "request
> >timed out" is returned, where it should then close the Command Prompt window.
> >
> >Anyone have any ideas ?
>
> Here's one: in the command prompt, run PING -n 1 <hostname> instead,
> redirect the output to a file, parse that file for "Request timed out.",
> loop if not found back to PING.
>
> Alternatively, under the OS here (XP), PING returns an ERRORLEVEL=1
> after a timeout. So:
> :Again
> PING -n1 <hostname> || EXIT
> GOTO Again
> might work.
>
> --
> Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
>

Re: Close Command Prompt upon ping time out ? by SpikeCraib

SpikeCraib
Sun Sep 09 08:46:02 PDT 2007

Thanks for the advice. I'll give it ago.



"Richard Mueller [MVP]" wrote:

> Spike Craib wrote:
>
> > I'm writing a vbscript to shutdown a number of remote computers. After the
> > script issues the remote shutdown to each computer it opens a Command
> > Prompt
> > window for each server and runs
> >
> > ping -t <hostname>
> >
> > for each server in the list. What I want to be able to do is get the
> > vbscript to call the Command Prompt and ping the server until a "request
> > timed out" is returned, where it should then close the Command Prompt
> > window.
> >
> > Anyone have any ideas ?
>
> I don't know of an easy way to do this. However, I have 3 example functions
> that ping computers in this link:
>
> http://www.rlmueller.net/PingComputers.htm
>
> The functions return True or False. These can be used in a loop to determine
> when the remote computer shuts down. For Example:
> =======
> intCount = 0
> blnDown = False
> Do Until intCount = 10
> If (PingComputer(strComputer, 1, 750) = False) Then
> Exit Do
> blnDown = True
> End If
> Wscript.Sleep 5000
> intCount = intCount + 1
> Loop
> ========
> I use a counter to avoid an infinite loop. The computer is pinged 10 times
> with a 5 second pause between each. After the loop if blnDown is True the
> machine was successfully shutdown. If blnDown is False machine still
> responded after 10 pings.
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>

Re: Close Command Prompt upon ping time out ? by Paul

Paul
Sun Sep 09 09:01:13 PDT 2007


"ThatsIT.net.au" <me@thatsit> wrote in message
news:4518631C-6874-4ACC-9DC2-53767670A034@microsoft.com...

> PS I think I made a comment about your site some years back, I know you
> have great abilities so one wonders why you have such a basic web site I
> think made from Visual Studio 6 Themes or maybe Front Page.
> I predict your going to say that it does the job and all that, but I think
> its time you updated it.
>
> But then at least yours is complete unlike mine that is a ever ongoing
> work in progress.

Whenever I have a choice between substance and style, I choose substance.

-Paul Randall



Re: Close Command Prompt upon ping time out ? by Richard

Richard
Sun Sep 09 09:30:55 PDT 2007


"ThatsIT.net.au" <me@thatsit> wrote in message
news:4518631C-6874-4ACC-9DC2-53767670A034@microsoft.com...
>
> "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
> message news:OHkGRQu8HHA.1416@TK2MSFTNGP03.phx.gbl...
>> Spike Craib wrote:
>>
>>> I'm writing a vbscript to shutdown a number of remote computers. After
>>> the
>>> script issues the remote shutdown to each computer it opens a Command
>>> Prompt
>>> window for each server and runs
>>>
>>> ping -t <hostname>
>>>
>>> for each server in the list. What I want to be able to do is get the
>>> vbscript to call the Command Prompt and ping the server until a "request
>>> timed out" is returned, where it should then close the Command Prompt
>>> window.
>>>
>>> Anyone have any ideas ?
>>
>> I don't know of an easy way to do this. However, I have 3 example
>> functions that ping computers in this link:
>>
>> http://www.rlmueller.net/PingComputers.htm
>>
>
> Richard I just went to your site, tried running your inventory script.
> When I open the excel file it shows that it could not find domain
> computers. I assume this is erroring on the ping because after running the
> script I can no longer ping computers manually using the same cmd window,
> I need to open a new cmd window to ping.
>
> any ideas

The program writes "Computer Not Found" in the third row if it cannot ping
the computer. It writes "WMI Not Installed" if it fails to connect with WMI.

You open a command window. You can ping computers. Then you run
Inventory.vbs and when it completes you no longer can ping? I never
experienced that in my tests, but I have not yet tested on Vista. The
program uses IE to display a progress message. Could IE be blocking the
pings because it was launched by the same process that is running the ping?
Could the firewall think the pings come from IE? I'm guessing.

When I experiment on another network I find that computers I know are not
there seem to respond to the ping, but with external addresses rather than
the internal addresses I would expect if they really were available. I get
"WMI Not Installed" for a computer I see in front of me not connected to the
domain. In fact, all unavailable computers respond with the same external
address. Maybe the NAT process in the router responds for the machine. I
have also found that IPv6 addresses fool the functions so they don't work on
Vista. I need to do more research.

>
> PS I think I made a comment about your site some years back, I know you
> have great abilities so one wonders why you have such a basic web site I
> think made from Visual Studio 6 Themes or maybe Front Page.
> I predict your going to say that it does the job and all that, but I think
> its time you updated it.
>
> But then at least yours is complete unlike mine that is a ever ongoing
> work in progress.
>

I work on the content but leave the basic web site design unchanged. I use
FrontPage. Many people have told me they like the simplicity. If I get time
I may update, but I have a lot of projects in the fire.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--



Re: Close Command Prompt upon ping time out ? by ThatsIT

ThatsIT
Mon Sep 10 06:49:39 PDT 2007


"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
message news:uCBnZ7v8HHA.3940@TK2MSFTNGP05.phx.gbl...
>
> "ThatsIT.net.au" <me@thatsit> wrote in message
> news:4518631C-6874-4ACC-9DC2-53767670A034@microsoft.com...
>>
>> "Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
>> message news:OHkGRQu8HHA.1416@TK2MSFTNGP03.phx.gbl...
>>> Spike Craib wrote:
>>>
>>>> I'm writing a vbscript to shutdown a number of remote computers. After
>>>> the
>>>> script issues the remote shutdown to each computer it opens a Command
>>>> Prompt
>>>> window for each server and runs
>>>>
>>>> ping -t <hostname>
>>>>
>>>> for each server in the list. What I want to be able to do is get the
>>>> vbscript to call the Command Prompt and ping the server until a
>>>> "request
>>>> timed out" is returned, where it should then close the Command Prompt
>>>> window.
>>>>
>>>> Anyone have any ideas ?
>>>
>>> I don't know of an easy way to do this. However, I have 3 example
>>> functions that ping computers in this link:
>>>
>>> http://www.rlmueller.net/PingComputers.htm
>>>
>>
>> Richard I just went to your site, tried running your inventory script.
>> When I open the excel file it shows that it could not find domain
>> computers. I assume this is erroring on the ping because after running
>> the script I can no longer ping computers manually using the same cmd
>> window, I need to open a new cmd window to ping.
>>
>> any ideas
>
> The program writes "Computer Not Found" in the third row if it cannot ping
> the computer. It writes "WMI Not Installed" if it fails to connect with
> WMI.
>
> You open a command window. You can ping computers. Then you run
> Inventory.vbs and when it completes you no longer can ping? I never
> experienced that in my tests, but I have not yet tested on Vista. The
> program uses IE to display a progress message. Could IE be blocking the
> pings because it was launched by the same process that is running the
> ping? Could the firewall think the pings come from IE? I'm guessing.
>


io ran it on win 2003 also giving the same result.

I can ping with cammand propmpt before running script, but script fails to
ping, then i cant ping after running the script till i open a new cmd
window.
I have ISA fire wall at the gateway, but windows firewall turned off on
internal NIC's.



> When I experiment on another network I find that computers I know are not
> there seem to respond to the ping, but with external addresses rather than
> the internal addresses I would expect if they really were available. I get
> "WMI Not Installed" for a computer I see in front of me not connected to
> the domain. In fact, all unavailable computers respond with the same
> external address. Maybe the NAT process in the router responds for the
> machine. I have also found that IPv6 addresses fool the functions so they
> don't work on Vista. I need to do more research.
>

that was my first though, but as I said I tried it on win 2003 also.

I also made a inventory script, but when ever a computer could not be
connected it reported properties of the last computer connected.
http://www.microsoft.com/technet/scriptcenter/csc/scripts/hardware/inventory/cschw032.mspx

So i was eager to try the ping first idea.


>>
>> PS I think I made a comment about your site some years back, I know you
>> have great abilities so one wonders why you have such a basic web site I
>> think made from Visual Studio 6 Themes or maybe Front Page.
>> I predict your going to say that it does the job and all that, but I
>> think its time you updated it.
>>
>> But then at least yours is complete unlike mine that is a ever ongoing
>> work in progress.
>>
>
> I work on the content but leave the basic web site design unchanged. I use
> FrontPage. Many people have told me they like the simplicity. If I get
> time I may update, but I have a lot of projects in the fire.
>

I think with the amount of solutions you have provided over the years It
would be easier to point people to your web site instead of explainaing over
and over.

I like Aaron Bertrand http://aspfaq.com/ but it seems to be more SQL bassed
than asp now and a bit hard to navigate



> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
>