Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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
Posted

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

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
×
×
  • Create New...