Re: Ping using VBS w/o active window

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Or you could bypass the run command altogether by using WMI

Function WMIPing(strSrv)

'function returns TRUE if successful contact was made.

On Error Resume Next

Dim oWMI,oRef

Const ReturnImmediately=&h10
Const ForwardOnly=&h20

strQuery="Select CSName,Status FROM Win32_OperatingSystem"

Set oWMI=GetObject("Winmgmts://"&strSrv)

If Err.Number Then
WMIPing=False
Exit Function
End If

Set oRef=oWMI.ExecQuery(strQuery,"WQL",ForwardOnly+ReturnImmediately)

If Err.Number Then
WMIPing=False
Exit Function
End If

for each item in oRef
If item.Status="OK" Then
WMIPing=True
Else
WMIPing=False
End If
Next

End Function


.



Relevant Pages

  • Re: ping anomally
    ... > Const FailIfNotExist = 0 ... Dim strTmpLine ... Exit Function ... pingChk = False ...
    (microsoft.public.scripting.wsh)
  • Re: ping anomally
    ... >> Const FailIfNotExist = 0 ... >> Dim oShell, oFSO, sTempFile, fFile ... > Exit Function ... > pingChk = False ...
    (microsoft.public.scripting.wsh)
  • Re: fastest way to create partitions
    ... Simple use dso - copying one partition from another. ... 'Const DSO_CloneOptions_cloneObjectProperties = 0 ... Dim DSODatabase ... Exit Function ...
    (microsoft.public.sqlserver.olap)
  • Re: another Blaster question
    ... Const ForReading = 1 ... Dim WshNetwork: Set WshNetwork = CreateObject ... ' Set variable to indicate the version of the Windows operating system ... Exit Function ...
    (microsoft.public.win2000.security)
  • Re: IE sequencing and cookie notification popups
    ... ' 10Apr04: accept cookies from hotmail. ... Dim SetWindowLong ' as object ... Const sDlgCaption = " Kookie Kruncher, ... ' notifications associated with that type of control. ...
    (microsoft.public.scripting.vbscript)