VBScript Bit-wise Operators
Working with Active Directory userAccountControl and VBScript (.vbs files) to check for a disabled account. This is a much better alternative to checking if the account is equal to "514"or "546". Read on to understand why! (Full VBScript included at the very bottom) ADS_UF_ACCOUNTDISABLE = 2 UserAccountControl = 514 If (UserAccountControl AND ADS_UF_ACCOUNTDISABLE) = ADS_UF_ACCOUNTDISABLE Then MsgBox UserAccountControl & " = Is Disabled!" Else MsgBox UserAccountControl & " = Is NOT Disabled!" End If The "AND" operator has two meanings in VBScript, depending on how it's used. "AND" is normally used for Boolean Logic , such as True AND False; however in VBScript, when used between two numbers, "AND"/"OR" is used as a " Bit-wise Logical Operator ", which is essential for comparing 1's and 0's underlying your decimal values. The tricky part was knowing to use ...