path of user desktop in batch files
I suppose you're under windows environnement, so %USERPROFILE%\Desktop
should be ok
This is the location of the current users desktop:
%userprofile%\desktop
If Desktop locations in a different folder only this will be correct answer:
Batch string:
for /f "usebackq tokens=3*" %%D IN (`reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) do set DESKTOP=%%D
V2 (Works with spaces) 4.10.2016:
for /f "usebackq tokens=1,2,*" %%B IN (`reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) do set DESKTOP=%%D
If you have non-ASCII symbols, you also need to convert ANSI encoding to OEM, example for cyrillic:
CHCP 1251 >Nul
for /f "usebackq tokens=1,2,*" %%B IN (`reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) do set DESKTOP=%%D
CHCP 866 >Nul
for /f "delims=" %%i IN ('echo %DESKTOP%') do set DESKTOP=%%i
Then just use:
echo %DESKTOP%