Adding Escapes of to variable in regset statement

I need to run a command to set the application compatibility flag to run as Windows XP SP3 for a legacy application installer (Remedy 7.1).

The following command does not work correctly since the \ characters need to be escaped. I have tried getting “escapes of” to add \ characters to the variable I already have but it does not seem to work. I think I have a syntax error but am unsure.

Base Command (runs but nothing happens):

regset64 "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]" "{(pathname of client folder of current site) & "\__Download\user_p11.exe"}"="WINXPSP3"

Here is what it looks like when exported from registry editor when I modify the user_p11.exe manually (when I pasted there was an extra “” character in the file paths):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
"C:\\Program Files (x86)\\BigFix Enterprise\\BES Client\\__BESData\\CustomSite_Fixlet_DEV_TEST_Site\\__Download\\user_p11.exe"="WINXPSP3"

Please modify like this.

I’ve edited your post to add preformat tags to make it readable in the forum. Without using the preformatting, certain characters like __ have special meanings that get translated in markdown. You can add code, command lines, and anything else you want displayed literally using the “quote” button -

Since regedit requires backslashes to be escaped in a value name or value data, you will have to add the escape characters. My usual solution for this is

regset64 "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]" "{concatenation "\\" of substrings separated by "\" of (pathname of client folder of current site & "\__Download\user_p11.exe")}"="WINXPSP3"

You might also be able to use
regset64 “[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]” "{concatenation “\” of substrings separated by “" of (pathname of download file “user_p11.exe”)}”=“WINXPSP3”

2 Likes