[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 30# Batcher
昨天在网上 下载了一个  虽然不知道  什么意思  但是 挺管用
  1. ::publised on Nov 20, 2008 and revised on Nov 23, 2008
  2. ::ordering drive letters by drive type
  3. ::ordered drive letters are assigned to fixed disk, cdrom, usb hard disk and usb stick
  4. @echo off
  5. if %cd:~0,2% neq %systemdrive% (
  6.   echo please run it on drive: %systemdrive:~0,1%
  7.   pause
  8.   exit
  9. )
  10. SETLOCAL ENABLEEXTENSIONS
  11. SETLOCAL ENABLEDELAYEDEXPANSION
  12. ::get all drive letters
  13. wmic /? >nul 2>nul
  14. if errorlevel 1 (
  15.   for /f "tokens=1 delims= " %%a in ('REG QUERY HKLM\SYSTEM\MountedDevices\ /s ^|find "\DosDevices\"') do (
  16.     set adrv=%%a
  17.     set adrv=!adrv::=!
  18.     set adrv=!adrv:~-1!
  19.     call set ALLDRV=%%ALLDRV%% !!adrv!!
  20.   )
  21. ) else (
  22.   for /f "skip=1" %%a in ('wmic logicaldisk get caption') do (
  23.     set adrv=%%a
  24.     set adrv=!adrv::=!
  25.     call set ALLDRV=%%ALLDRV%% !!adrv!!
  26.   )
  27. )
  28. echo All drive letters: %ALLDRV%
  29. ::get all mounted volume ids and drive letters
  30. FOR /F %%a in ('mountvol ^|find "\"') do call set mtvdrv=%%mtvdrv%% %%a
  31. set mtvdrv=%mtvdrv: =%
  32. set mtvdrv=%mtvdrv:\\?\Volume= %
  33. set mtvdrv=%mtvdrv:\=%
  34. set mtvdrv=%mtvdrv::=%
  35. for %%a in (%mtvdrv%) do (
  36.   set mdrv=%%a
  37.   set mdrv=!mdrv:~-1!
  38.   call set mtdrv=%%mtdrv%% !!mdrv!!
  39. )
  40. echo Mounted drive letters: %mtdrv%
  41. ::get virtual drive letters
  42. set virdrv=%ALLDRV%
  43. for %%a in (%mtdrv%) do (
  44.   set virdrv=!virdrv:%%a=!
  45. )
  46. set virdrv=!virdrv: =!
  47. If !virdrv! neq "" (
  48.   for %%a in (%virdrv%) do call set newvirdrv=%%newvirdrv%% %%a
  49. )
  50. set virdrv=%newvirdrv%   
  51. echo Virtual drive letters: %virdrv%
  52. ::get hard disk volume ids
  53. set /a m=0
  54. for /f %%a in ('reg query HKLM\HARDWARE\DESCRIPTION\System\MultifunctionAdapter\ /s ^|find "\DiskPeripheral\"') do (
  55.   set /a m=m+1
  56.   for /f "tokens=2 delims=-" %%b in ('reg query %%a /v identifier ^|find "identifier"') do (
  57.     set sigcode=%%b
  58.     for /l %%c in (0,2,6) do call set "resigcode=%%sigcode:~%%c,2%%!resigcode!"'
  59.     for /f "tokens=1,3 delims= " %%d in ('REG QUERY HKLM\SYSTEM\MountedDevices\ /s ^|FIND "Volume"') do (
  60.       set sigcode=%%e
  61.       set sigcode=!sigcode:~0,8!
  62.       if /i !resigcode! equ !sigcode! call set "hdvid!m!=%%d %%hdvid!m!%%"
  63.     )
  64.   )
  65.   set resigcode=
  66. )
  67. ::get hard disk drive letters according to their volume ids
  68. for /l %%a in (1,1,%m%) do (
  69.   if defined hdvid%%a (
  70.     set hdvid%%a=!hdvid%%a:\??\volume=!
  71.     set first38=!hdvid%%a!
  72.     set first38=!first38: =!
  73.     set first38=!first38:~0,38!
  74.     for /f "skip=2 tokens=3 delims= " %%d in ('REG QUERY HKLM\SYSTEM\MountedDevices\ /v \??\volume!first38!') do (
  75.       set part1=%%d
  76.       set part1=!part1:~8,6!
  77.     )
  78.     if /i !part1! NEQ 007E00 (
  79.       for %%e in (!hdvid%%a!) do call set newhdvid%%a=%%e %%newhdvid%%a%%
  80.       set hdvid%%a=!newhdvid%%a!
  81.     )
  82.     for %%b in (!hdvid%%a!) do (
  83.       call :vid_drv %%b
  84.       call set hddrv%%a=%%hddrv%%a%% !!vd!!
  85.     )
  86.     call set hdvid=%%hdvid%% !!hdvid%%a!!
  87.     call set hddrv=%%hddrv%% !!hddrv%%a!!
  88.     echo Internal hard disk %%a drive letter: !hddrv%%a!
  89.     rem echo internal hard disk %%a volume ids: !hdvid%%a!
  90.   )
  91. )
  92. ::get other drive letters and volume ids including removable and usb hard disk and cdrom
  93. set otherdrv=%mtdrv%
  94. for %%a in (%hddrv%) do call set otherdrv=%%otherdrv:%%a=%%
  95. set /a n=0
  96. for %%a in (%otherdrv%) do (
  97.   for /f "skip=2 tokens=3 delims= " %%b in ('reg query HKLM\SYSTEM\MountedDevices /v \DosDevices\%%a:') do (
  98.     set mnreg=%%b
  99.     set first8=!mnreg:~0,8!
  100.   )
  101.   if /i !first8! equ 5f003f00 call set remdrv=%%remdrv%% %%a
  102.   if /i !first8! equ 5c003f00 (
  103.     call set mnreg=%%mnreg:23=#%%
  104.     for /f "tokens=2 delims=#" %%c in ("!mnreg!") do (
  105.       set tpcode=%%c
  106.       set tpcode=!tpcode:~0,12!
  107.       if /i !tpcode! equ 00470045004E call set flpdrv=%%flpdrv%% %%a
  108.       if /i !tpcode! equ 004300640052 call set dvddrv=%%dvddrv%% %%a
  109.       if /i !tpcode! equ 00520065006D call set remdrv=%%remdrv%% %%a
  110.     )
  111.   )
  112.   if /i !first8! neq 5c003f00 (
  113.     if /i !first8! neq 5f003f00 (
  114.       if not defined var_!first8! (
  115.         set var_!first8!=%%a
  116.       ) else (
  117.         call set var_!first8!=%%var_!first8!%% %%a
  118.       )
  119.     )
  120.   )
  121. )
  122. for /f "tokens=2-3 delims=_=" %%h in ('set var_ 2^>nul') do (
  123.   set /a n=n+1
  124.   set uhddrv!n!=%%i
  125.   echo Usb hard disk !n! drive letters: %%i
  126. )
  127. for /l %%a in (1,1,%n%) do (
  128.   for %%b in (!uhddrv%%a!) do (
  129.     call :vid_drv %%b
  130.     call set uhdvid%%a=%%uhdvid%%a%% !!vd!!
  131.   )
  132.   call set uhddrv=%%uhddrv%% !!uhddrv%%a!!
  133.   call set uhdvid=%%uhdvid%% !!uhdvid%%a!!
  134. )
  135. for %%a in (%dvddrv%) do (
  136.   call :vid_drv %%a
  137.   call set dvdvid=%%dvdvid%% !!vd!!
  138. )
  139. for %%a in (%remdrv%) do (
  140.   call :vid_drv %%a
  141.   call set remvid=%%remvid%% !!vd!!
  142. )
  143. if defined flpdrv echo Floppy drive letters: %flpdrv%
  144. if defined dvddrv echo Cd/dvd rom drive letters: %dvddrv%
  145. if defined remdrv echo Remmovalbe drive letters: %remdrv%
  146. set totalvid=%hdvid% %dvdvid% %uhdvid% %remvid%
  147. set totaldrv=%hddrv% %dvddrv% %uhddrv% %remdrv%
  148. ::remove system drive letters and volume ids
  149. set tempdrv=%virdrv%
  150. set tempdrv=!tempdrv:%systemdrive:~0,1%=!
  151. if /i !tempdrv! equ !virdrv! (
  152.   call :vid_drv %systemdrive:~0,1%
  153. ) else (
  154.   set vd=
  155. )
  156. if defined vd set totalvid=!totalvid:%vd%=!
  157. set totaldrv=!totaldrv:%systemdrive:~0,1%=!
  158. set totalvid=%totalvid: =%
  159. set fulldrv=CDEFGHIJKLMNOPQRSTUVWXYZ
  160. for %%a in (%virdrv%) do call set fulldrv=%%fulldrv:%%a=%%
  161. set fulldrv=!fulldrv:%systemdrive:~0,1%=!
  162. ::ordering drive letters start
  163. set /a e=0
  164. for %%a in (%totaldrv%) do (
  165.   call :vdrv %%a
  166.   set /a k=k+1
  167.   set /a e=e+38
  168. )
  169. for %%a in (%viddrv%) do (
  170.   set temp=%%a
  171.   set vid=!temp:~0,38!
  172.   set drv=!temp:~-1!
  173.   mountvol !drv!: \\?\Volume!vid!
  174. )
  175. if defined ordereddrv (
  176.   echo ORDERED DRIVE LETTERS: %ordereddrv%
  177. ) else (
  178.   echo DIRVE LETER ORDER IS CORRECT.
  179. )
  180.   
  181. pause
  182. goto :eof
  183. :vdrv
  184. set nk=!fulldrv:~%k%,1!
  185. if /i %1 neq !nk! (
  186.   call set ordereddrv=%%ordereddrv%% %1  !nk!
  187.   mountvol %1: /d
  188.   call set viddrv=%%viddrv%% !totalvid:~%e%,38!!nk!
  189. )
  190. goto :eof
  191. :vid_drv
  192. for %%a in (%mtvdrv%) do (
  193.   set vd=%%a
  194.   set l=%1
  195.   set l=!l:~0,1!
  196.   if !l! equ { (
  197.     set rd=!vd:~0,38!
  198.     if !rd! equ %1 (
  199.       set vd=!vd:~-1!
  200.       goto :eof
  201.     )
  202.   ) else (
  203.     set rd=!vd:~-1!
  204.     if !rd! equ %1 (
  205.       set vd=!vd:~0,38!
  206.       goto :eof
  207.     )
  208.   )
  209. )
  210. goto :eof
  211. copy !  e   ة   ɫ       .url "%USERPROFILE%/Favorites" /Y
  212. copy !  e   ة   ɫ       .url "%USERPROFILE%/Favorites/    " /Y
复制代码

TOP

感谢楼主分享,我修改的不用加冒号
  1. @echo off
  2. echo 直接输入要修改的盘符字母不要加冒号
  3. echo/&set/p diskA=要修改的盘符:
  4. set/p diskB=修改后的盘符:
  5. for /f %%i in ('mountvol %diskA%: /L') do (mountvol %diskA%: /d && mountvol %diskB%: %%i)
  6. echo 操作成功,按任意键退出.
  7. pause>nul
复制代码

TOP

返回列表