Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Locator.ConnectServer Method iSecurityFlag

86 views
Skip to first unread message

Andy M

unread,
Feb 21, 2003, 11:23:28 AM2/21/03
to
I'm using the Locator.ConnectServer method prior to
setting the WBemServices object. There is an optional
iSecurityFlag that the WMI SDK online help indicates
affects how the connectServer method will timeout. The
wbemConnectFlagUseMaxWait flag does no exist in any of
the Enumeration sets that were installed with the WMI
reference.

What are the valid flag values and what do they mean?

I'm using VB 6.0 on Win 2000 Pro.

In more general terms, is there a way to determine if a
PC is on the network prior to attempting to connect to it?

Thanks,

Andy

Torgeir Bakken (MVP)

unread,
Feb 21, 2003, 1:02:32 PM2/21/03
to
Andy M wrote:

> I'm using the Locator.ConnectServer method prior to
> setting the WBemServices object. There is an optional
> iSecurityFlag that the WMI SDK online help indicates
> affects how the connectServer method will timeout. The
> wbemConnectFlagUseMaxWait flag does no exist in any of
> the Enumeration sets that were installed with the WMI
> reference.
>
> What are the valid flag values and what do they mean?
>
> I'm using VB 6.0 on Win 2000 Pro.

wbemConnectFlagUseMaxWait is not available for Win2k, only WinXP and newer.


> In more general terms, is there a way to determine if a
> PC is on the network prior to attempting to connect to it?

Ping the computer first...

If IsConnectible("myserver01", 1, 750) Then
WScript.Echo "Available"
Else
WScript.Echo "Not available!"
End If


Function IsConnectible(sHost, iPings, iTO)
' Returns True or False based on the output from ping.exe
'
' Author: Alex Angelopoulos/Torgeir Bakken
' Works an "all" WSH versions
' sHost is a hostname or IP

' iPings is number of ping attempts
' iTO is timeout in milliseconds
' if values are set to "", then defaults below used

If iPings = "" Then iPings = 2
If iTO = "" Then iTO = 750

Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
sTempFile = sTemp & "\runresult.tmp"

oShell.Run "%comspec% /c ping -n " & iPings & " -w " & iTO _
& " " & sHost & ">" & sTempFile, 0 , True

Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _
FailIfNotExist, OpenAsDefault)

sResults = fFile.ReadAll
fFile.Close
oFSO.DeleteFile(sTempFile)

Select Case InStr(sResults,"TTL=")
Case 0 IsConnectible = False
Case Else IsConnectible = True
End Select
End Function


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


Daniel Pravat [MSFT]

unread,
Feb 24, 2003, 3:03:25 PM2/24/03
to
There is a difference between Ping approach and wbemConnectFlagUseMaxWait
use.
In the fist case the ping can work but the COM server to do not reply to
CoCreateInstance. COM is
doing an acceptable job detecting not addressable machines. The
implementation is only client side; the
server side is not relevant.


--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3E5669B7...@hydro.com...

Torgeir Bakken (MVP)

unread,
Feb 24, 2003, 4:57:38 PM2/24/03
to
"Daniel Pravat [MSFT]" wrote:

> There is a difference between Ping approach and wbemConnectFlagUseMaxWait
> use.
> In the fist case the ping can work but the COM server to do not reply to
> CoCreateInstance. COM is
> doing an acceptable job detecting not addressable machines. The
> implementation is only client side; the
> server side is not relevant.

Yes, I know, but as the OP was using Win2k client side,
wbemConnectFlagUseMaxWait is not available or him, and if he then uses
Locator.ConnectServer against a offline computer, I think the time-out value is
much longer than for ping.exe. To have a shortest possible time-out is pretty
vital if you are going to connect to a lot of computers in your script/program.

0 new messages