Jump to content

how to write this in AutoIT


BoogY
 Share

Recommended Posts

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

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

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

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...