OK, this will prove that I’m just a beginner. What my intent was to verify that a user has the three string values listed in my script. (And, now I realize I also need to check for the string value of OPEN)
So, I wrote this script and what is happening is that a user’s registry ends up with multiple values (OPEN10 … 20 … 30 and more) of the same string. I need to check the string value of all OPENx values and compare it to the list of three acceptable strings. If the string does not match I need to move on to the next value. If it’s a duplicate, I need to delete it. If it doesn’t exist I need to create it. Also, if I delete a value (example, OPEN3) because it is a duplicate I need to start renaming the next OPENx value. Boy, this gets complicated.
Code:
$Index = 0
$ValueIndex = 1
$MyAppValue = 1
:Loop1
$ValueName = ENUMVALUE ("HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\microsoft excel", $Index)
If @ERROR = 0
If $ValueName = "OPEN" + $ValueIndex
If @ERROR = 0
$RegValue = ReadValue ("HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\microsoft excel", $ValueName)
Select
Case $MyAppValue = 1
$OpenValue = "/R C:\Program Files\MyApp\XLFILES\BPSXL32.XLL"
Case $MyAppValue = 2
$OpenValue = "/R C:\Program Files\MyApp\XLFILES\BH_EXT.XLA"
Case $MyAppValue = 3
$OpenValue = "/R C:\Program Files\MyApp\XLFILES\BPSMA32.XLL"
EndSelect
If $RegValue = $OpenValue
$MyAppValue = $MyAppValue + 1
EndIf
EndIf
$ValueIndex = $ValueIndex + 1
EndIf
$Index = $Index + 1
goto Loop1
Endif
If $MyAppValue = 1 And $ValueIndex = 1
$ValueIndex = 1
Else
If $MyAppValue > 1
Goto EndFS
EndIf
EndIf
writevalue("Software\Microsoft\Office\8.0\Excel\microsoft excel", "OPEN" + $ValueIndex, "/R C:\Program Files\MyApp\XLFILES\BPSXL32.XLL", "REG_SZ")
$ValueIndex = $ValueIndex + 1
writevalue("Software\Microsoft\Office\8.0\Excel\microsoft excel", "OPEN" + $ValueIndex, "/R C:\Program Files\MyApp\XLFILES\BH_EXT.XLA", "REG_SZ")
$ValueIndex = $ValueIndex + 1
writevalue("Software\Microsoft\Office\8.0\Excel\microsoft excel", "OPEN" + $ValueIndex, "/R C:\Program Files\MyApp\XLFILES\BPSMA32.XLL", "REG_SZ")
:EndFS
I hope I am making sense.