tense -
I use this for single-NIC systems. Not fully set for Win2K devices, but should help you out. Items 1-3 used in DHCP section of my script, so I included here for you. Item 1 is where I define script-wide variables to certain registry keys. Item 2 defines O/S level of client and if Domain Controller. Item 3 defines user rights on workstation for WinNT/2K devices.
Bill

code:

; REM ** 1. Set reusable variables for Current Control Set registry key, Windows Current Version key, and installed NIC
$HKLMAPPS = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths"
SELECT
CASE (@INWIN = 1)
$HKLMSS = READVALUE ("HKEY_LOCAL_MACHINE\SYSTEM\Select", "Current")
$CurCtrStr = "ControlSet00"+$HKLMSS
$HKLMSCCS = "HKEY_LOCAL_MACHINE\System\$CurCtrStr"
$HKCUSMWCV = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion"
$HKLMSMWCV = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion"
$NetCard = ENUMKEY ("$HKLMSCCS\Services\NetBT\Adapters", 0)
CASE (@INWIN = 2)
$HKCUCP = "HKEY_CURRENT_USER\Control Panel"
$HKCUSMWCV = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion"
$HKCUSMWCVP = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies"
$HKLMSCCS = "HKEY_LOCAL_MACHINE\System\CurrentControlSet"
$HKLMSMWCV = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion"
ENDSELECT


; REM ** 2. Determine O/S type and version level, and determine role of the Win2K/WinNT system
SELECT
CASE (@INWIN = 1)
$OSDir = READVALUE ("$HKLMSMWCV", "SystemRoot")
$OSKey = ""
$OSNam = ""
$OSPid = READVALUE ("$HKLMSMWCV", "ProductId")
$OSSvc = READVALUE ("$HKLMSMWCV", "CSDVersion")
$OSVer = READVALUE ("$HKLMSMWCV", "CurrentVersion")
$OSTyp = UCASE (READVALUE ("$HKLMSCCS\Control\ProductOptions", "ProductType")) ; REM ** NT Server role.
$OSSui = UCASE (READVALUE ("$HKLMSCCS\Control\ProductOptions", "ProductSuite")) ; REM ** Enterprise & Terminal Server.


SELECT
CASE (@DOS >= 5.0) $OS = "Win2K" $OSLvl = "Pro" $OSNam = "Microsoft Windows 2K" $WinDC = "1"
CASE (1) $OS = "WinNT" $OSLvl = "Wksta" $OSNam = "Microsoft Windows NT" $WinDC = "1"
ENDSELECT


SELECT
CASE ($OSTyp="LANMANNT") $OSLvl = "Domain Controller" $WinDC = "0"
CASE ($OSTyp="SERVERNT") $OSLvl = "Member Server" $WinDC = "0"
ENDSELECT
$OSAbv = $OS


CASE (@INWIN = 2)
; REM ** Ver info from MS Tech Article Q158238: "How to Determine Version of Win95/98/ME in Use" (2001.04.10)
$OS = "Win9x"
$OSDir = READVALUE ("$HKLMSMWCV", "SystemRoot")
$OSKey = READVALUE ("$HKLMSMWCV", "ProductKey")
$OSNam = READVALUE ("$HKLMSMWCV", "ProductName")
$OSPid = READVALUE ("$HKLMSMWCV", "ProductId")
$OSVer = READVALUE ("$HKLMSMWCV", "VersionNumber")
$OSSvc = LTRIM (RTRIM (UCASE (READVALUE ("$HKLMSMWCV", "SubVersionNumber"))))
$WinDC = "1"
SELECT
CASE ($OSVer >= "4.90.3000") $OSAbv = "WinME" $OSLvl = "OEM"
CASE ($OSVer >= "4.10.2222") $OSAbv = "Win98" $OSLvl = "SE"
CASE ($OSVer >= "4.10.1998") $OSAbv = "Win98" $OSLvl = "OEM"
CASE (($OSVer >= "4.03.1214") AND ($OSSvc = "C")) $OSAbv = "Win95" $OSLvl = "SR 2.5"
CASE (($OSVer >= "4.03.1212") AND ($OSVer =< "4.03.1214")) $OSAbv = "Win95" $OSLvl = "SR 2.1"
CASE ($OSVer >= "4.00.1111") $OSAbv = "Win95" $OSLvl = "SR 2"
CASE (($OSVer >= "4.00.950") AND ($OSSvc = "A")) $OSAbv = "Win95" $OSLvl = "SP 1"
CASE ($OSVer >= "4.00.950") $OSAbv = "Win95" $OSLvl = "OEM"
CASE (1) $OSAbv = "Unknown" GOSUB ScriptError EXIT
ENDSELECT
CASE (1) $OSAbv = "Unknown" GOSUB ScriptError EXIT
ENDSELECT


; REM ** 3. Define_user privilege. Note: For 'INGROUP \\@WKSTA' to work properly you must create a Global Domain group,
; REM ** add Admin/Power Users to this group, then add the Global group to local workstation Admin/Power Users groups.
SELECT
CASE INGROUP ("Domain Admins") $Privilege = "Domain Admin"
CASE INGROUP ("\\@WKSTA\Administrators") $Privilege = "Local Admin"
CASE INGROUP ("\\@WKSTA\Power Users") $Privilege = "Power User"
CASE (1) $Privilege = "User"
ENDSELECT


:CheckDHCP
; rem ###########################################################################
; rem ## Checks to make sure that the DHCP settings are correct. ##
; rem ## If incorrect the script edits the registery to insert the correct ##
; rem ## values. If the script has problems doing so (general error, ##
; rem ## user dosen't have rights to modify the registry, etc.) a message ##
; rem ## is sent to the system administrators alerting them to this fact. ##
; rem ## ; rem ###########################################################################

; REM ** Local variables in use by this function are:
$DsplyMsg = "Your DHCP settings have been updated."
$EmailMsg = "DHCP settings updated on computer @WKSTA."
$ErrorMsg = "Could not update the DHCP settings on your workstation. A system administrator has been notified."
$NicYN = 0


; REM ** Finds the various current DHCP settings. Script set for single-NIC system only.
SELECT
CASE (($WinDC = "0") OR ($OS = "Win2K"))
$Console = WRITELINE (10, "$AbortMsg" + $CR)
$Status = $Abort
RETURN
CASE (($OS = "WinNT") AND ($Privilege = "User"))
$Console = WRITELINE (10, "User does not have permissions to change DHCP settings." + $CR)
GOSUB ScriptError
RETURN
CASE ($OS = "WinNT")
$KeyName = ENUMKEY ("$HKLMSMWCV\NetworkCards\", 0)
$NicType = READVALUE ("$HKLMSMWCV\NetworkCards\$KeyName","ServiceName")
$DhcpVal = READVALUE ("$HKLMSCCS\Services\$NicType\Parameters\TCPIP","EnableDHCP")
$ChkKey = ("$HKLMSCCS\Services\$NicType\Parameters\TCPIP")
CASE (1)
$KeyName = ENUMKEY ("$HKLMSCCS\Services\Class\NetTrans\" , $Index)
$ChkKey = ("$HKLMSCCS\Services\Class\NetTrans\$KeyName")
ENDSELECT


$IPVal = READVALUE ("$ChkKey", "IPAddress")


SELECT
CASE ((@INWIN = 1) AND ($DhcpVal <> "1")) GOSUB DHCP_SET
CASE ($IPVal <> "0.0.0.0") GOSUB DHCP_SET
CASE (1)
$Console = WRITELINE (10, "Verified DHCP Settings: $IPVal" + $CR)
$Status = $OK
ENDSELECT
RETURN


:DHCP_SET
$RegKey = "$HKLMSCCS\Services"
SELECT
CASE ($OS = "Win2K")
$Console = WRITEVALUE ("$RegKey\$NicType\Parameters\TCPIP" , "EnableDHCP" , "1" , "REG_DWORD")
$Console = WRITEVALUE ("$RegKey\$NicType\Parameters\TCPIP" , "IPAddress" , "0.0.0.0" , "REG_MULTI_SZ")
$Console = WRITEVALUE ("$RegKey\$NicType\Parameters\TCPIP" , "SubnetMask" , "0.0.0.0" , "REG_MULTI_SZ")
$Console = WRITEVALUE ("$RegKey\DHCP" , "Start" , "2" , "REG_DWORD")
; $Console = WRITEVALUE ("$RegKey\NetBT\Parameters\Interfaces\Tcpip_$NicType" , "NameServerList" , "" , "REG_MULTI_SZ") ; REM ** WINS Servers IPs
$Console = WRITEVALUE ("$RegKey\NetBT\Parameters" , "EnableDNS" , "1" , "REG_DWORD")
CASE ($OS = "WinNT")
$Console = WRITEVALUE ("$RegKey\$NicType\Parameters\TCPIP" , "EnableDHCP" , "1" , "REG_DWORD")
$Console = WRITEVALUE ("$RegKey\$NicType\Parameters\TCPIP" , "IPAddress" , "0.0.0.0" , "REG_MULTI_SZ")
$Console = WRITEVALUE ("$RegKey\$NicType\Parameters\TCPIP" , "SubnetMask" , "0.0.0.0" , "REG_MULTI_SZ")
$Console = WRITEVALUE ("$RegKey\DHCP" , "Start" , "2" , "REG_DWORD")
; $Console = WRITEVALUE ("$RegKey\NetBT\Adapters\$NicType" , "NameServer" , "" , "REG_SZ") ; REM ** WINS Server1 IP
; $Console = WRITEVALUE ("$RegKey\NetBT\Adapters\$NicType" , "NameServerBackup" , "" , "REG_SZ") ; REM ** WINS Server2 IP
$Console = WRITEVALUE ("$RegKey\NetBT\Parameters" , "EnableDNS" , "1" , "REG_DWORD")
CASE (1)
$Console = WRITEVALUE ("$RegKey\Class\NetTrans\$KeyName" , "IPAddress" , "0.0.0.0" , "REG_SZ")
$Console = WRITEVALUE ("$RegKey\Class\NetTrans\$KeyName" , "IPMask" , "0.0.0.0" , "REG_SZ")
DELVALUE ("$RegKey\VxD\MSTCP" , "NodeType")
DELVALUE ("$RegKey\VxD\MSTCP" , "ScopeID")
ENDSELECT


$IPVal = READVALUE ("$ChkKey", "IPAddress")
SELECT
CASE ($IPVal = "0.0.0.0")
$Console = WRITELINE (10, "Updated DHCP Settings: $IPVal" + $CR)
$Reboot = "DHCP"
$Status = $Updat
CASE (1)
$Console = WRITELINE (10, "Failure verifying DHCP Settings." + $CR)
GOSUB ScriptError
ENDSELECT
RETURN


[This message has been edited by bleonard (edited 06 June 2001).]