Writing% ~ DP0 to the registry using REG ADD

I solved the issue of inserting% DATE% into the REG_SZ registry value ( see link ), but now I am facing a slightly different problem trying to insert% ~ DP0 (long source path) into the registry value using REG ADD in a .BAT script. It will not be done, and I am sure, because I am doing something wrong.

reg add "hklm\software\acme" /v "TestValue" /d "%~dp0" /t REG_SZ /f

I also tried to set the value for the variable first, but this does not work either. It happens that it inserts an extended path without the preceding double quote, but with the ending double quote, and then with a REG / error error? syntax etc.

SET VX=%~DP0
reg add "hklm\software\acme" /v "TestValue" /d "%VX%" /t REG_SZ /f

Does anyone see what I'm doing wrong?

+5
source share
1 answer

% ~ dp0 '\' (, 'c:\temp \'), escape , . , trailing\ :

reg add "hklm\software\acme" /v "TestValue" /d "%~dp0\" /t REG_SZ /f
+5

All Articles