;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       NacStatus() 
;; 
;;ACTION         Returns TRUE if the local system is NAC isolated 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION	 1.0 - 2012/02/22 
;; 
;;HISTORY	 1.0 - 2012/02/22 - Initial Release 
;; 
;;SYNTAX         NacStatus() 
;; 
;;PARAMETERS     none 
;; 
;;REMARKS        Returns TRUE when the netmask is 255.255.255.255, indicating that NAC 
;;               (Network Access Control) has not yet validated the system and will not 
;;               allow network access. Generally, a /32 netmask is combined with static 
;;               routes to remediation servers. The DCs and remediation servers are the 
;;               only systems that can be accessed while in "admission status". 
;; 
;;RETURNS        TRUE if the netmask is /32 
;; 
;;DEPENDENCIES   none 
;; 
;;TESTED WITH    NT4, W2K, WXP, W2K3 
;; 
;;EXAMPLES        
;;                $Count = 60 ; wait up to 60 seconds 
;;                While NacStatus() And $Count 
;;                  Sleep 1 
;;		    $Count = $Count - 1 
;;                Loop 
;;                If NacStatus() 
;;                  'Cannot run login script while in NAC Admission Control status.' ? 
;;                  Quit 0 
;;                EndIf 
;;                ; Network available - logon script can continue... 
; 
Function NACStatus()
 
  Dim $_					; temp var 
  Dim $_SubKeyCounter				; Subkey enum counter 
  Dim $_CurrentSubKey				; registry subkey 
  Dim $_Key					; reg value 
  Dim $_WorkRegKey				; built registry path 
  Dim $_Regkey[1]				; array of registry paths 
  Dim $_Guid					; adapter GUID 
 
 
  ; Define the registry keys 
  $_RegKey[0] = 'HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}'
  $_RegKey[1] = 'HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'
 
 
  ; init the enumeration index and array index 
  $_SubKeyCounter = 0
  $NACStatus      = 0
 
 
  ; Enumerate all of the keys that are LAN adapters 
  $_CurrentSubKey = EnumKey($_RegKey[0], $_SubKeyCounter)
  If @ERROR
    Exit @ERROR							; exit now if can't read registry! 
  EndIf
 
  While @ERROR = 0
    $_Key = Val(ReadValue($_RegKey[0] + '\' + $_CurrentSubKey, 'Characteristics'))
    If $_Key = 132 Or $_Key >= 32768				; physical nic or virtual team 
      $_Guid = ReadValue($_RegKey[0] + '\' + $_CurrentSubKey, 'NetCfgInstanceId')		; NIC GUID 
      $_WorkRegKey = $_RegKey[1] + '\Interfaces\' + $_Guid
      $_ = Val(ReadValue($_WorkRegKey, 'EnableDHCP'))				; DHCP boolean 
      $_Key = IIf($_ = 1, 'Dhcp', '')
      If Trim(Join(Split(ReadValue($_WorkRegKey, $_Key + 'SubnetMask'), '|'), ' ')) = '255.255.255.255'
        $NACStatus      = 1
        Exit 0
      EndIf
    EndIf
    $_SubKeyCounter = $_SubKeyCounter + 1			; increment the enumeration index 
    $_CurrentSubKey = EnumKey($_RegKey[0], $_SubKeyCounter)	; get the next key 
  Loop
 
Exit 0
 
EndFunction