@echo off
for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop"') do Set a=%%j
echo 你当前桌面路径是:%a%
pause
rem 下面是修改桌面路径
set "a=D:\桌面"
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop" /t REG_SZ /d %a%
pause
话说jd08139的答案虽然对但实在是冗余 你可以这么写
如果是XP
set d=%USERPROFILE%\桌面
如果是W7
set d=%USERPROFILE%\desktop
即可
set a=%USERPROFILE%\桌面
echo %a%
set a=%userprofile%\桌面