Get a string with %SystemRoot% does not present it CMD BATCH

Viewed 105

I am querying from registry:

for /f "tokens=3" %%i in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl" /v "DumpFile"') do set dump=%%i

When I do echo %dump% I get: %SystemRoot%\MEMORY.DMP But what I want is: C:\Windows\MEMORY.DMP

Because %SystemRoot% is built-in var which locates the SystemRoot (in this case C:\Windows)

Thanks for your help

1 Answers

No explanation, just an answer:

@For /F Tokens^=2* %%G In ('""%__AppDir__%reg.exe" Query "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /V "DumpFile" 2>NUL"')Do @Call Set "dump=%%~H"

If Echoing is already turned off, and you can guarantee that the contents of your %PATH% and %PATHEXT% variables are unmodified on all systems this script will be run on, you can use the syntax below:

For /F "Tokens=2,*" %%i In ('Reg Query "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /V "DumpFile" 2^>NUL') Do Call Set "dump=%%~j"
Related