I'm struggling in Windows 10 with get desktop path of current user with this script:
ECHO OFF
FOR /F "skip=2 tokens=2,*" %%A IN ('reg.exe query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Desktop"') DO SET "UserDesktopPath=%%B"
ECHO UserDesktopPath is: %UserDesktopPath%
DIR %UserDesktopPath%
PAUSE
Basically its works when registry key have custom value (e.g. C:\Test\Desktop):
But don't work, when registry key have default value for desktop like: %USERPROFILE%\Desktop
Then my script will have this output:
Any ideas why cmd script can't read system variable %USERPROFILE%?