Failure to append to current registry entry

(imported topic written by Keverhar)

Help, please?

It seems simple enough -

If the registry entry does not exist, create it and write the new value

If the registry entry exists and is empty, write the new value

If the registry entry exists and contains a value, append the new value (preceeded by a comma) to the existing value

Here’s the action script:

parameter “AddList” = “company.com,b.usa.net,.global.net”
parameter “CurrentList” = “”

if (CONCATENATION “|” of NAMES OF VALUES OF KEY “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters” OF REGISTRY AS STRING AS lowercase CONTAINS “searchlist” as lowercase) THEN parameter “CurrentList” = “{VALUE “SearchList” OF KEY “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters” OF REGISTRY AS STRING}” & “,”

parameter “NewList” = parameter “CurrentList” & parameter “AddList”

Createfile until end-reg-edit-commands
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
“SearchList” = parameter “NewList”
end-reg-edit-commands

move __createfile setup.reg
wait regedit /s setup.reg

The action indicates all lines complete but the registry entry does not change.

(imported comment written by BrianPGreen)

I think the best way to figure this out is to change “move __createfile setup.reg” to move the file to a well-known location, like “C:\debug_setup.reg”. Then, after the action has run, you can look at C:\debug_setup.reg to see what’s actually being passed to the regedit tool.

(imported comment written by Keverhar)

Apparently the parameter is not being set from the query to the registry.

if (CONCATENATION “|” of NAMES OF VALUES OF KEY “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters” OF REGISTRY AS STRING AS lowercase CONTAINS “searchlist” as lowercase) THEN parameter “CurrentList” = “{VALUE “SearchList” OF KEY “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters” OF REGISTRY AS STRING}” & “,”

(imported comment written by BrianPGreen)

The main problem is that you’re missing curly braces in some places for where relevance substitution is supposed to happen. For example

parameter “NewList” = parameter “CurrentList” & parameter “AddList”

should instead be:

parameter “NewList” = “{parameter “CurrentList” & parameter “AddList”}”

Here’s what I think is a working version of the action that you want:

parameter “AddList” = “company.com,b.usa.net,.global.net”

parameter “CurrentList” = “{if exists value “searchlist” whose ( it as string != “” ) of key “HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters” of registry then value “searchlist” whose ( it as string != “” ) of key “HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters” of registry as string & “,” else “”}”

parameter “NewList” = “{parameter “CurrentList” & parameter “AddList”}”

Createfile until end-reg-edit-commands

REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]

“SearchList” = “{parameter “NewList”}”

end-reg-edit-commands

delete setup.reg

move __createfile setup.reg

wait regedit /s setup.reg

(imported comment written by Keverhar)

Thank you Brian!