Creating registry key with expandable string value named (Default)?

You can't do it using RegEdit. (or at least I don't think that you can!)..

Use the reg.exe command line to pull it off. reg.exe add <key_name> /ve /t REG_EXPAND_SZ /d "%path%" (for instance).


For the record, other ways to create a (Default) value of type REG_EXPAND_SZ:

  1. If you prefer creating keys/values directly in RegEdit, Which makes string values with embedded quotes and slashes much easier to compose, you can then let Regedit do the work of escaping special characters and encoding unicode strings. To create a (Default) value of type REG_EXPAND_SZ:

    1. Create the key.
    2. Create a value named temp of type REG_EXPAND_SZ with the value you want for (Default).
    3. Export to a .reg file.
    4. Edit the file, cutting "temp"to the clipbard then replacing with @. then, add a new line, pasting "temp" followed by =-.
    5. Save and merge.

enter image description here

Registry Export:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\DummySoftware\Path]
"temp"=hex(2):25,00,55,00,73,00,65,00,72,00,50,00,72,00,6f,00,66,00,69,00,6c,\
  00,65,00,25,00,5c,00,44,00,75,00,6d,00,6d,00,79,00,53,00,6f,00,66,00,74,00,\
  57,00,61,00,72,00,65,00,00,00



After editing:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\DummySoftware\Path]
@=hex(2):25,00,55,00,73,00,65,00,72,00,50,00,72,00,6f,00,66,00,69,00,6c,\
  00,65,00,25,00,5c,00,44,00,75,00,6d,00,6d,00,79,00,53,00,6f,00,66,00,74,00,\
  57,00,61,00,72,00,65,00,00,00

"temp"=-


After merging: enter image description here

  1. PowerShell is also an option.

     $Splat = @{
       'Path'     = 'HKCR:\SOFTWARE\DummySoftware2\Path'
       'Value     = '%UserProfile%\DummySoftware2'
       'ItemType' = 'ExpandString'
       'Force'    = $False
     }
     New-Item $Splat
    

enter image description here