Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use REG_EXPAND_SZ from the commandline?
    text
    copied!<p>I was reading the Windows Commandline Documentation (Win+F1) about the commands that modify the Windows registry, particularly the the "reg add" command.</p> <pre><code>reg add HKCU\testfolder /t REG_EXPAND_SZ /v Stokrotka /d "%systemroot%\system32" </code></pre> <p>Now, I don't know how this was designed to work. When I invoke the command above, the variable <code>%systemroot%</code> gets expanded to <code>C:\Windows</code>. I've tried the following not to make the variable to expand, but there is no way I could force it not to:</p> <ul> <li>escaping the `%%`'s with an `%, ^, \` - doesn't work even if I use double quotes around <li>using the single quotes '' around the whole /d string <li>use `setlocal setdelayedexpansion`? sth like: </ul> <p><code># (setlocal enabledelayedexpansion) &amp;&amp; (reg add HKCU\testfolder /t REG_EXPAND_SZ /v Stokrotka /d "!systemroot!\system32") &amp;&amp; (setlocal disabledelayedexpansion)</code></p> <p>The variable 'data' (/d) field is either like <code>^%systemroot^%</code> or like <code>!systemroot!</code> or just expands to C:\windows . I could probably use the .reg file to accomplish my task, but I simply don't want to do it.<br> I thought that maybe there is something wrong with the program that I use to display the variable contents (<code>regedit / regedt32 / reg query (commandline)</code>), but after checking this is probably not the case.<br> Any ideas? I'm mainly interested how the variable value should look like in the regedit window, should it be like :<code>"%systemroot%\system32"</code> or <code>"C:\windows\system32"</code> to be properly expanded by other programs. Regards. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload