Registry add with variable

(imported topic written by Shlomi91)

Hi,

i have been having a good time trying to add (or modify) a registry containing a system variable (%userprofile%).

what i want:

i want that the following string will appear (as is): “HKEY_LOCAL_MACHINE\SOFTWARE\SAP\SAP Shared” with value “SapWorkDir” and data “%userprofile%\SapWorkDir”

what i tried:

i tried getting to it by using both Bigfix action script regset (regset "

HKEY_LOCAL_MACHINE\SOFTWARE\SAP\SAP Shared

" “SapWorkDir”=%userprofile%\SapWorkDir)

and using the dos command in bigfix action script (dos reg add “HKLM\Software\SAP\Sap Shared” /v Sapworkdir /t REG_EXPAND_SZ /d %userprofile%\SapWorkDir /f)

what i got:

when using Bigfix action script i got a “complete” notice, but registry entry was not changed at the client side.

when using the “dos” command i got the registry value / data, but i got my own profile folder (“c:\documents and settings\shlomi\sapworkdir” instead of the variable string “%userprofile%\sapworkdir”)

if i used a hard-coded location, (for example, c:\temp\sapworkdir) it worked (of course)

any ideas?

thanks,

Shlomi

(imported comment written by BenKus)

Hey Shlomi,

I think you might have a syntax issue with your regset command where you forgot some quotes around the value. Can you try:

regset “HKEY_LOCAL_MACHINE\SOFTWARE\SAP\SAP Shared” “SapWorkDir”="%userprofile%\SapWorkDir"

Ben

(imported comment written by Shlomi91)

Hi Ben,

as a matter of fact, this is what i tried first.

however, when it didnt work i went to the CustomAuthoringTrainingGuide-6-17-2005.pdf, and there in page 64 (under “registry commands”) it had a syntax example like this: Regset <“registry key”> <“value name”>= , without the qoutes around “value”.

in any case, this way i get the “sap shared” key, but not the value “sapworkdir” or the data “%userprofile%\sapworkdir”

i’d appreciate any help on this.

thanks,

Shlomi

(imported comment written by JonFan)

Hey Shlomi,

I think you just need to escape the backslash. Try this:

regset "

HKEY_LOCAL_MACHINE\SOFTWARE\SAP\SAP Shared

" “SapWorkDir”="%userprofile%\SapWorkDir"

Hope this helps!

-Jon

(imported comment written by Shlomi91)

Hi John,

Worked like a charm!

Thanks a lot,

Shlomi