Command line supression

G

Guest

I have a VBA utility (lifted from VBScript, and run in VBA in Access) that
looks like:

Public Function PingPC(strComputer As String)

Dim strPingResults As String
Dim objShell, objScriptExec

Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec( _
"ping -n 2 -w 1000 " & strComputer)
strPingResults = LCase(objScriptExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
If InStr(strPingResults, "destination net unreachable") Then
Debug.Print strComputer & "did not respond to ping."
Else
Debug.Print strComputer & " responded to ping."
End If
Else
Debug.Print strComputer & " did not respond to ping."
End If

End Function

It works great, except...

....that annoying little command prompt window shows up on the screen when
you ping.

Now, this fuction is called from another routine, that loops through a range
of IP addresses. That's right ... you guessed it ... for each ping, that
little window pops up.

And, according to the web site I lifted this from
(http://msdn.microsoft.com/library/d...ry/en-us/wmisdk/wmi/wmi_tasks__networking.asp),
using WMI doesn't work on Win2K or Win95/98 desktops. You have to use the
old-fashioned command line ping method.

Is there any way to ping the PC via the command line, but suppress the
command line window from appearing on the screen?

Thanks!
 
D

Douglas J Steele

See whether you can use the code Randy Birch has at
http://vbnet.mvps.org/code/internet/ping.htm

Obligatory warning: Randy's site is aimed at VB programmers. Because of
differences between the Form model in Access and VB, some of his samples
don't port cleanly to Access: some fussing is required. A quick look at this
sample, though, didn't reveal any obvious issues.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top