Delta01 Posted April 19, 2008 Posted April 19, 2008 (edited) Can someone tell me why the below code doesn't work, please. expandcollapse popup#include <Constants.au3> MsgBox(64, "Returned", _CheckProcessConnect("firefox.exe") & @CR & @ERROR) ;=============================================================================== ; ; Description: Checks if a process is connected - to the internet / to a specific IP ; Syntax: _CheckProcessConnect($sProcess,$iIp = False) ; Parameter(s): $sProcess = Processname / Process ID to look for ; $iIp = The IP that the Process should be connected to [ optional! ] ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 and sets @error ; 1 = No connection exists ; 2 = Process does not exist ; 3 = No german Windows ; Author(s): qon ; Note(s): None ; ;=============================================================================== Func _CheckProcessConnect($sProcess,$iIp = False) $iPID = ProcessExists($sProcess) If $iPID = 0 then SetError(2) Return 0 EndIf $foo = Run(@ComSpec & " /c netstat -on", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($foo) If @error Then ExitLoop Switch $iIp Case False If StringInStr(" " & $line & " ",$iPID) and StringInStr(" " & $line & " ","HERGESTELLT") Then Return 1 EndIf Case Else If StringInStr(" " & $line & " ",$iPID) and StringInStr(" " & $line & " ","HERGESTELLT") and StringInStr(" " & $line & " ",$iIp) Then Return 1 EndIf EndSwitch Wend SetError(1) Return 0 EndFunc If there is a connection to the internet, it should return 1 Edited April 19, 2008 by Delta01
herewasplato Posted April 20, 2008 Posted April 20, 2008 You might take a look at how others use netstat and stdiohttp://www.autoitscript.com/forum/index.ph...st&p=489687 [size="1"][font="Arial"].[u].[/u][/font][/size]
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