Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

suppress cmd window 1

Status
Not open for further replies.

bn2hunt

MIS
May 15, 2003
203
US
Is there a way to suppress the popup window, when the
Code:
Set oExec = Ws.EXEC("ping -n 2 -w 500 " & hostname)
line is executed. I can suppress them if I run a script using cscript but I would prefer the cleaner look, no windows, of wscript.

Thanks for any help that may be provided

Dan

Code:
Function Reachable(Hostname)
	Dim WshShell, oExec
        reachable = false
	Set oExec = Ws.EXEC("ping -n 2 -w 500 " & hostname)
	Do While oExec.Status = 0
	     WScript.Sleep 100
	Loop
	Do While oExec.StdOut.AtEndOfStream <> True
        	retstring = oExec.StdOut.ReadLine
		if instr(retString, "Reply")>0 then
			reachable = true
			exit do
		end if
	Loop
end function
 
the .Run method has , 0, True

where the 0 is the window style which is surpressed.
i presume Exec doesnt have that???
 
oh, does the ping command have a return code if it worked or not??? might be an alternatice, that way you can defo use .RUn, 0, True
 


intReturn = WshShell.Run("ping ....", 0, True)

If intReturn = 0 Then
'yippie
Else
'oh dear
End If
 
Ping does not appear to return anything but a 0. I think becuase as far as the computer is concerned the run command worked wether or not the computer was able to be pinged or not.

Dan
 
sorry for the wild goose chase ddnwolf, i was checking %errorlevel% in a cmd window
 
cant see anything for cmd either, i.e cmd /silent ping...
 
your code appears to work in testing, a little slower than the ws.exec method so there might be a trade off. I am going to try putting the new method in a bigger script and see what happens. I will let you know.

DDnWolff
 
For WinXP or Win2003 machines you may consider the Win32_PingStatus WMI class.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
We still have a few windows 2000 servers and professionals that are hanging around so pingstatus won't work for us at this time. But I will keep in in mind when we finally get those out of use.

The following code is working.
Thanks for the help

DDNWolff
Code:
hostname = "999.999.999.999"

if reachable(hostname) then


Function Reachable(Hostname)
        intReturn = Ws.run("ping -n 2 -w 500 " & hostname, 0, True)
	If intReturn = 0 Then
		   reachable = true
	Else
		reachable = false
	End If


end function

Thanks for the help
 
I wrote this which does a similar job, obviously doesn't include ttl values etc but works never the less!!!!

__________________________________________________________

input = InputBox("Please enter IP address(s) of machine(s) to test, each seperated by a "":"" character", "My connectivity programme")

If input ="" Then
WScript.Echo("Please enter IP Address(s) of Teminal(s)/Host(s) to ping computer name to Ping, each seperated by a "":"" character")

Else

strMachines = input
aMachines = Split(StrMachines, ":")

For Each machine In aMachines
Set ObjPing = GetObject("winmgmts:")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")

For Each objStatus in ObjPing
If IsNull(ObjStatus.StatusCode) Or objStatus.StatusCode<>0 Then
MsgBox machine & " Is not online - Check IP and connectivity",,"my app"


Else


MsgBox machine & " is online and responding",,"my app"
End If
Next
Next
End If




ChrisCj21
MCSE, A+, N+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top