HI,

I have a problem with this function that return always the @ERROR=2 when i check a subkey registry whether it exists or not.

Here the script section:

;--------Start------------------------------

$scKeyFull = "HKEY_LOCAL_MACHINE\Software\BdG\AMO"

DIM $RegParameters[22]
DIM $RegParamValue[22]

$RegParameters[0] = "SoftwareDistribution"
$RegParameters[1] = "City"
$RegParameters[2] = "Building"
$RegParameters[3] = "Floor"
$RegParameters[4] = "Office"
$RegParameters[5] = "Block"
$RegParameters[6] = "Template"
$RegParameters[7] = "PCModel"
$RegParameters[8] = "AssetCode"
$RegParameters[9] = "Zone"
$RegParameters[10] = "NetServer"
$RegParameters[11] = "SerialNumber"
$RegParameters[12] = "ClonerID"
$RegParameters[13] = "FullName"
$RegParameters[14] = "CloningDate"
$RegParameters[15] = "MasterVersion"
$RegParameters[16] = "DiskVersion"
$RegParameters[17] = "SoftwareLevel"
$RegParameters[18] = "Department"
$RegParameters[19] = "MonitorNumber"
$RegParameters[20] = "MonitorModel"
$RegParameters[21] = "MonReqExecuted"

;*****************************************************************************************

; Inizializzo la Chiave SoftwareDistribution a 0

WRITEVALUE ($scKeyFull,$RegParameters[0],"0","REG_SZ")

;*****************************************************************************************
; Riempio l'array dei valori con i valori del registry se presenti, altrimenti a vuoto

$Index = 0
$SubKeyValue = ""
DO
? $scKeyFull + "\" + $RegParameters[$Index]
$SubKeyValue = $scKeyFull + "\" + $RegParameters[$Index]
? $SubKeyValue
? @ERROR
If EXISTKEY($SubKeyValue)=0
? @ERROR
$RegParamValue[$Index] = READVALUE ($scKeyFull, $RegParameters[$Index])
? $RegParamValue[$Index] ; se esiste
Else
@ERROR?
WRITEVALUE ($scKeyFull,$RegParameters[$Index],"","REG_SZ")
$RegParamValue[$Index] = READVALUE ($scKeyFull, $RegParameters[$Index])
? $RegParamValue[$Index] ; se non esiste
EndIf
$Index= $Index + 1
? $Index
UNTIL $Index < 22

;--------END----------------

If you run this script You ca see the value @Error that become 2: what it means?

Then i try a test only with an IF statement and it is the same. Here is the Example:

;--------start------------------
If EXISTKEY ($scKeyFull + "\" + $RegParameters[1]) <> 0
WRITEVALUE ($scKeyFull,$RegParameters[1],"Zurich","REG_SZ")
EndIf

;-------end-----------------