Mingre Posted April 19, 2013 Share Posted April 19, 2013 Hello again,More than a week ago, I made this thread [Resolved] How to put ping() or similar alternative function a timeout asking for a faster alternative for the ping function. The last post states that I found a code good enough for what I want to achieve._list() Func _list() Local $foo, $sActiveLine, $line $foo = Run(@ComSpec & " /c net view ", @SystemDir, @SW_HIDE, 2) While 1 $sActiveLine = StdoutRead($foo) If @error Then ExitLoop If StringLeft($sActiveLine, 2) = "\\" Then $line &= StringReplace($sActiveLine, "\\", "") & @CRLF EndIf WEnd $line = StringReplace($line, " ", "") $line = StringReplace($line, @LF, "") $line = StringSplit($line, @CR) TCPStartup() For $i = 1 To $line[0] - 1 $result = Ping($line[$i], 1) If Not @error Then ConsoleWrite('>ONLINE : ' & $line[$i] & @CRLF) Else ConsoleWrite('+OFFLINE : ' & $line[$i] & @CRLF) EndIf Next EndFunc ;==>_listEarlier I also made this thread [sOLVED] stdoutread() question which includes the modification of the code. From how I phrased the function, the code presumably lists the turned-on computers in the local network. But only the first time.Code as fixed by guinness#include ConsoleWrite(ListOnline() & @CRLF) Func ListOnline() Local $iPID = Run(@ComSpec & " /c net view ", @SystemDir, @SW_HIDE, $STDOUT_CHILD) Local $sActiveLine = "", $sLines = "" While 1 $sActiveLine = StdoutRead($iPID) If @error Then ExitLoop $sLines &= $sActiveLine WEnd Return $sLines EndFunc ;==>ListOnlineThe problem begins after I shutdown a computer in the local network. It still shows the turned-off computers. Perhaps you noticed that the mod was simply removing the ping function (because it's too laggy).As for displaying the already turned-off computers, I know the problem isn't with AutoIt but with Windows XP's net view. While I was searching, I found this: http://www.pcreview.co.uk/forums/net-view-doesnt-refresh-often-t3671801.html. Like what the user said, the Microsoft's ping takes a long time to load when it's used for turned-off computers. I even tried making use of MS' ping timeout but the shortest time it can get is about 2000ms. (And if am not mistaken, it takes a little longer with AutoIt's ping, ~4000ms?)I also had tried using cunningt's _PingLikeMicrosoft() as suggested by Robjong but it still takes around 2000ms.So my questions are:1. Is there a workaround to my problem, i.e., detecting which among the computers displayed by net view are actually turned-off?2. Is there a way to clear net view cache using AutoIt so I could just re-run net view instead of pinging every displayed computer?Thank you! Link to comment Share on other sites More sharing options...
BrewManNH Posted April 19, 2013 Share Posted April 19, 2013 I think you're going to have to compromise between speed and functionality. With networking, you usually can't have both working well, one is going to suffer if you want the other. There are a LOT of network scanners out there and they all suffer from the same thing, they take a long time to populate the list, if you're doing it dynamically. If you do a once in a while update of the list, then speed isn't an issue, but if you want real-time, you're probably not going to be able to achieve it. Mingre 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now