在安装数个硬盘的情况下有时会产生盘符交叉问题, 特写此P
注:盘符 卷标 与 卷 是不同的感念,不要混淆.- @echo off
- setlocal enabledelayedexpansion
- if "%~1"=="" (
- call copy "%~0" "%windir%.\..\"
- start "" "%windir%.\..\%~nx0" %~dp0
- exit /b
- )
- set "oldPath=%*"
- echo 工作路径1:%oldPath%
- echo 工作路径:%~dp0
- echo.======== Ver:1.0 ==================== 发布日期: 2010-09-07 ==============
- echo. · 1. 自动
- echo. · 2. 根据Volume.txt的顺序修改盘符
- echo.====================== Copyright@ by hf-g 2010-09-07 [彭城] =============
- set "choice="&set/p choice=输入你的选择(1/2/q):
- if /i "%choice%"=="q" goto end
- echo %choice%|findstr "^[12]$">nul 2>nul&&goto choice%choice%
- goto end
- ::==============================================================
- :choice1
- ::备份及查找各硬盘分区卷的装入点
- cd.>Volume_old.txt
- for /f "delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do (
- set var=%%i
- set drive=!var:~-2!
- fsutil fsinfo drivetype !drive!|find "固定">nul && (for /f "delims= " %%a in ('mountvol !drive! /l') do set "%%a=1" & echo !drive! %%a>>Volume_old.txt)
-
- )
-
- ::根据不同硬盘的枚举顺序修改盘符,跳过C:盘
- if not exist Volume.txt (mountvol|findstr "\\\\\?\\Volume">Volume.txt)
- set "char=DEFGHIJKLMNOPQRSTUVWXYZ"
- @echo on
- set/a count=0
- for /f "skip=1 usebackq delims= " %%a in ("Volume.txt") do (
- call echo !%%a! ++ +%%char:~!count!,1%%+
- if "!%%a!"=="1" (call mountvol %%char:~!count!,1%%: /d & call mountvol %%char:~!count!,1%%: %%a & set/a count+=1)
- )
- @echo off
- goto:eof
- ::==============================================================
- :choice2
- ::根据Volume.txt的顺序修改盘符,跳过C:盘
- if not exist Volume.txt (mountvol|findstr "\\\\\?\\Volume">Volume.txt)
- ::生成Volume_320.txt文件,并删除盘符(跳过C:盘).
- cd.>Volume_320.txt
- for /f %%a in ('mountvol^|findstr "\\\\\?\\Volume :\\"') do (
- set "Volume=%%a"
- if "!Volume:~-2!"==":\" (
- if /i not "%%a"=="%SystemDrive%\" mountvol !Volume:~0,2! /d
- call set "Volume_!count!=!Volume:~0,2! %%Volume_!count!%%"
- ) else (
- set/a num+=1
- set "count=00!num!"
- set "count=!count:~-3!"
- set "Volume_!count!= %%a"
- ))
- set Volume_
- for /f "tokens=2 delims==" %%a in ('set Volume_') do echo %%a>>Volume_320.txt
-
- @echo on
- set /p "Volfile=输入已设定好的Volume文件:"
- if not defined Volfile (set "Volfile=Volume_320.txt")
- copy "%oldPath%.\%Volfile%" "%windir%.\..\"
- for /f "tokens=1,2 usebackq delims= " %%a in ("%Volfile%") do (
- if /i not "%%a"=="%SystemDrive%" (
- call echo +%%a+ ++ +%%b+
- call mountvol %%a %%b
- ))
- @echo off
- ::==============================================================
- pause
- pause
- :end
- goto:eof
- ::==============================================================
复制代码
|