IP address script - takes too long

From: Mark Whidby (mark.whidby_at_manchester.ac.uk)
Date: 03/01/05


Date: 1 Mar 2005 22:25:04 GMT

I'm new to scripting so I hope someone can tell me what's wrong
here. The following script is copied from one of the examples from
Microsoft and outputs a PC's IP addresses:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root
\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where
IPEnabled=TRUE")

wscript.echo "Start in script",Time
For Each IPConfig in IPConfigSet
  If Not IsNull(IPConfig.IPAddress) Then
    For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
       WScript.Echo IPConfig.IPAddress(i)
    Next
  End If
Next
wscript.echo "Finished in script",Time

I call it with this batch file:

@echo off
echo.|time|find "current"
cscript c:\colinux\batch\stub.vbs //nologo
echo.|time|find "current"

Here is some sample output (edited to hide the true IP address):

d:\temp>c:\colinux\batch\stub
The current time is: 22:16:20.36
Start in script 22:16:20
nnn.nn.148.142
192.168.0.1
Finished in script 22:16:20
The current time is: 22:16:30.97

My question is - why does it take about 10 seconds to pass control
back to the batch file? It must be something to do with the
particular PC I run it on (my work PC) as it runs OK on my home PC.
Any ideas?



Relevant Pages

  • Re: The system cannot find the file specified - Win32_NetworkAdapt
    ... I'm pretty sure I've confirmed it was a 'fasle positive' by Kaspersky. ... The script is running stand-alone - although you are correct that it ... For Each IPConfig in IPConfigSet ... Dim m_WshNetwork ...
    (microsoft.public.scripting.vbscript)
  • Re: The system cannot find the file specified - Win32_NetworkAdapt
    ... The script is running stand-alone - although you are correct that it was ... I've confirmed this error is generated the moment variable IPConfigSet is ... because the code you pasted doesn't dim intCtr, ... Dim m_WshNetwork ...
    (microsoft.public.scripting.vbscript)
  • Re: The system cannot find the file specified - Win32_NetworkAdapt
    ... The script is running stand-alone - although you are correct that it was ... I've confirmed this error is generated the moment variable IPConfigSet is ... because the code you pasted doesn't dim intCtr, ... Dim m_WshNetwork ...
    (microsoft.public.scripting.vbscript)
  • Re: Multiple MAC Addresses to Output into an Access Table
    ... Dim strComputer, objWMIService, IPConfigSet, IPConfig, i, i2 ... MACAddr1 = IPConfig.MACAddress ... Unfortunately now I need a script that can pull and separate the wired ...
    (microsoft.public.scripting.vbscript)
  • Re: Compare IP addresses
    ... For StartOctet = StartOctet To EndOctet ... If CheckLocalIPAddress() = True Then ... For Each IPConfig in IPConfigSet ... > How do I compare two numbers in script? ...
    (microsoft.public.scripting.wsh)