本帖最后由 ygqiang 于 2015-2-1 00:22 编辑
[已解决]xp/win7系统下,各种不同情况,获取桌面路径。通用性比较强的bat命令是?- @echo off
- for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop"') do set "desktop_dir=%%j"
- echo %desktop_dir%
- pause
-
- for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do set "dktop2=%%b"
- echo %Desktop2%
- pause
复制代码 这2个命令,有3个不同的地方。都有啥差别?
xp/win7系统、各种不同环境/不同情况下,获取桌面路径通用性比较强的命令,应该如何写?
————————————————————————————————————
更新下:win7 64系统下, 刚测试了下。。只有下面这个代码好用。- @echo off
- for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop"') do set "desktop_dir=%%j"
- echo %desktop_dir%
- copy "%desktop_dir%\*.*" c:\000
- pause
复制代码
|