Variable path in *.reg file

windows-registry

I've been a lurker here for a long time and nearly always found a question to my answer using the search question, but this time I need some help. I want to create a script/.reg file that automatically registers some Powerpoint AddIns to the computers in my domain. Pretty straightforward, it needs to do this:

[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\PowerPoint\AddIns\PPMacro]
"AutoLoad"=dword:ffffffff 
"Path"="C:\\Users\\%USERNAME%\\AppData\\Roaming\\Microsoft\\AddIns\\PPMacro.ppam"

Basically, it makes an entry in Powerpoint's registry pointing it to a macro in the AppData folder. However, while this 'Path' key is a static path to the macro, I would like this static path to have a variable username in the script, since this differs per computer I want to apply the script to.

I cannot seem to figure out how to do this. It keeps literally putting %USERNAME% in the key, which is logical since it's in parenthesis, but I don't know how I am supposed to do it. Could anyone help me out here? Thanks in advance!

Best Answer

Use the REG command:

REG ADD "HKCU\Software\Microsoft\Office\16.0\PowerPoint\AddIns\PPMacro" /v Path /t REG_SZ /d "C:\\Users\\%USERNAME%\\AppData\\Roaming\\Microsoft\\AddIns\\PPMacro.ppam" /f