思路:从注册表中提取当前系统“桌面”对应的目录,一般是“ %USERPROFILE%\桌面 ”(实际对应:C:\Documents and Settings\Administrator),赋值为变量 aa,COPY是用到%aa%,结果提示找不到路径,原来aa的值是“%USERPROFILE%\桌面”,COPY无法找到对应字符,直接显示成 copy "E:\Program Files\EDU\直接采集.txt" "%USERPROFILE%\桌面\直接采集.txt",而不是显示成 copy "E:\Program Files\EDU\直接采集.txt" "C:\Documents and Settings\Administrator\桌面\直接采集.txt",
setlocal enabledelayedexpansion
set "r=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
for /f "skip=2 tokens=3" %%b in ('reg query "%r%" /v "desktop"') do set aa=%%b
pause
copy "E:\Program Files\EDU\直接采集.txt" "%aa%\直接采集.txt"