You would use EXISTKEY to determine if key exists.
Use ADDKEY to add if does not.
Use READVALUE to get value contents to compare with settings you wish to make.

Below is example for writing values for IE Proxy settings using an array. Variables '$Override' and '$Proxy' determined elsewhere in my script.

Realistically, you would not use ADDKEY to make this registry key.
IE would have created during installation, and if IE not installed no point in adding this key.
But, does illustrate the process for you.

Variables '$RegSet' are the settings you wish the registry entries to be.

As for NTDOC's observation 'Legal Notice' not allowed in Win9x, Win98 does support but Win95 does not. Substitute 'Windows' for 'Windows NT' in his script to utilize. These all detailed in Zero Admin kits, or Policy files.

Bill

code:

$HKCUSMWCV = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion" ; REM ** Actually determined elsewhere in my script


$x=0
DIM $RegKey[6]
DIM $RegVal[6]
DIM $RegSet[6]
DIM $RegTyp[6]


$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "AutoDetect" $RegSet[$x] = "0" $RegTyp[$x] = "REG_DWORD" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "ProxyEnable" $RegSet[$x] = "1" $RegTyp[$x] = "REG_DWORD" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "EnableHttp1.1" $RegSet[$x] = "1" $RegTyp[$x] = "REG_DWORD" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "ProxyHttp1.1" $RegSet[$x] = "1" $RegTyp[$x] = "REG_DWORD" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "ProxyOverride" $RegSet[$x] = "$Override" $RegTyp[$x] = "REG_SZ" $x=$x+1
$RegKey[$x]="$HKCUSMWCV\Internet Settings" $RegVal[$x] = "ProxyServer" $RegSet[$x] = "$Proxy" $RegTyp[$x] = "REG_SZ" $x=$x+1


$x2=0
DO
$RC = EXISTKEY ($RegKey[$x2]) ; REM ** Only make key if does not exist
IF (@ERROR <> 0)
ADDKEY ($RegKey[$x2])
ENDIF


$TmpVal = SUBSTR ($RegVal[$x2], 1, LEN ($RegVal[$x2]))
$TmpSet = SUBSTR ($RegSet[$x2], 1, LEN ($RegSet[$x2]))
$TmpStr = READVALUE ("$RegKey[$x2", $RegVal[$x2])


SELECT
CASE ($TmpStr = $RegSet[$x2]) $Msg = "Verified"
CASE ($TmpStr <> $RegSet[$x2])
$Console = WRITEVALUE ($RegKey[$x2], $RegVal[$x2], $RegSet[$x2], $RegTyp[$x2])
SELECT
CASE (@ERROR = 0)
$Msg = "Updated"
$Status = $Updat
CASE (1)
$EmailMsg = "Could not update $TmpVal settings for $UserID on @WKSTA"
$Err = "1"
$Msg = "Error updating"
ENDSELECT
ENDSELECT


$Console = WRITELINE (10, "$Msg $TmpVal: $TmpSet" + $CR)
IF ($Status <> $Updat) $Status = $OK ENDIF


$x2=$x2+1
UNTIL $x2=$x

IF $Err = "1" GOSUB ScriptError ENDIF


[This message has been edited by bleonard (edited 24 May 2001).]