|
本帖最后由 yyz2191958 于 2023-7-12 19:24 编辑
问题解决:
(for /f "tokens=1-2*" %%a in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /s^|find "Desktop"') do @echo;%%c)>#.txt
for /f %%a in (#.txt) do XCOPY /y "%~dp0png\*.ico" "%%a\"
***************************************************************
更加优秀代码:
for /f "tokens=1-2*" %%a in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /s^|find "Desktop"') do call XCOPY /y "%~dp0png\*.ico" "%%c\"
****************************************************
原来的问题:
已有代码:for /f %%a in (#.txt) do XCOPY /y "%~dp0png\*.ico" "%%a\"
其中:
#.txt内容为:D:\桌面\Desktop——————这种情况成功
#.txt内容为:%USERPROFILE%\Desktop — 这种情况不成功
上面是同一电脑的不同系统
************************************************************
#.txt是读取注册表里面桌面路径生成的:
(for /f "tokens=1-2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /s^|find "Desktop"') do @echo;%%c)>#.txt
************************************************************
怎样才能够使两种情况都成功?谢谢
|
|