Sign in to follow this  
Followers 0
BoogY

how to write this in AutoIT

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0