BoogY Posted September 22, 2009 Share Posted September 22, 2009 Hi there ... Can somone help me with this code : For $objStatus in $colPings If is null ($objStatus.StatusCode) or $objStatus.StatusCode <> 0 Then MsgBox(0,"Computer OFF","Computer did not respond.") Else MsgBox(0,"Computer ON","Computer did respond.") EndIf Next How can you write this line [if is null ($objStatus.StatusCode) or $objStatus.StatusCode <> 0 Then] THE IS NULL PART ???!!! Thanks a lot Link to comment Share on other sites More sharing options...
exodius Posted September 22, 2009 Share Posted September 22, 2009 You should include the rest of the code so we can see what you're trying to accomplish, afaik, AutoIt doesn't have a direct "Is Null" equivalent, but that may not be necessary anyways depending on what you're doing. **Supporting post: http://www.autoitscript.com/forum/index.php?showtopic=94361 Link to comment Share on other sites More sharing options...
jvanegmond Posted September 22, 2009 Share Posted September 22, 2009 Or maybe if this is VB (you only posted a snippet, not describing what $objStatus is): http://www.autoitscript.com/forum/index.php?showtopic=64966 github.com/jvanegmond Link to comment Share on other sites More sharing options...
BoogY Posted September 22, 2009 Author Share Posted September 22, 2009 here is the entire function : Func iscompON() $strComputer = GUICtrlRead($txtTFS) $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colPings = $objWMIService.ExecQuery _ ("Select * From Win32_PingStatus where Address = '"& $IPAdress &"'") For $objStatus in $colPings If ($objStatus.StatusCode) = "" or $objStatus.StatusCode <> 0 Then MsgBox(0,"Computer OFF","Computer did not respond.") Else MsgBox(0,"Computer ON","Computer did respond.") EndIf Next EndFunc Link to comment Share on other sites More sharing options...
jvanegmond Posted September 22, 2009 Share Posted September 22, 2009 It says here: http://msdn.microsoft.com/en-us/library/aa394350(VS.85).aspx That StatusCode = 0 means "Succes" and everything bigger than 0 is an error. Func iscompON() $strComputer = GUICtrlRead($txtTFS) $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colPings = $objWMIService.ExecQuery _ ("Select * From Win32_PingStatus where Address = '"& $IPAdress &"'") For $objStatus in $colPings If ($objStatus.StatusCode <> 0) Then MsgBox(0,"Computer OFF","Computer did not respond.") Else MsgBox(0,"Computer ON","Computer did respond.") EndIf Next EndFunc github.com/jvanegmond 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