;************************************************************************* ; Script Name: Sorting Hat ; Author: Richard Niemeier ; Date: 4/24/2009 ; Description: Evaluates Subnets defined in Subnets.Ini File to determine which site PC is located and the run correct script for that site ; ;************************************************************************* ;Variables to make script easier to modify ;Just a variable to identify possible locations script is used at $SiteName="????" ;Not really important just left here thinking I might need it $Domain="????" ;Used in following line to locate additional filesscript is dependent upon $SiteCode="???" ;Should be noted the Functions.kix file needs to include- ;Binary IP ;Subnet ;@LSERVER is the variable logon server, this I feels makes the script more dynamic and able to respond to failed DC's $SubNetsIni = @LSERVER + "\NETLOGON\SE\" + $SiteCode + "\subnets.ini'i" SetTime @LSERVER CALL @LServer + "\NETLOGON\SE\" + $SiteCode + "\FUNCTION.kix" ;this loads functions in to memory for current script being executed $List = ReadProfileString($SubNetsIni,SubNets,'') $a = Split($list,CHR(10),-1) ;? $list For Each $Element In $a $SubnetV =ReadProfileString($SubNetsIni,"SubNets" ,"$Element") DIM $ipstart $IPSplit=Split($Subnetv,",",-1) $C=0 For Each $Value In $IPSplit If $C=0 $IPStart=$Value $C=$C+1 ;?$IPStart ;remove comment to make verbose for troubleshooting Else If $C=1 $IPMask=$Value $C=$C+1 ;?$IPMask ;remove comment to make verbose for troubleshooting Else $SiteCode=$Value ?"Trying...."+$Sitecode ;This section determines if the PC is actually assigned an IP that is part of this network DIM $PCIP $PCIP = @IPADDRESS0 If subnet($PCIP, $IPStart, $IPMask) = 1 ? "This ipaddress is in the specified subnet ***" + $Sitecode + "***" GoTo ISINIP Else ? "This ipaddress is not in the specified subnet ***" + $Sitecode + "***" Sleep 1 GoTo NOTINIP EndIf :ISINIP Sleep 1 Run @LSERVER + "\NETLOGON\SE\"+"US"+ $SiteCode + "_login.bat" Quit :NOTINIP EndIf EndIf Next Next ?"All sites evaluated you must be traveling" Sleep 1 Quit