|
victor888 发表于 2013-6-12 09:16
更新了,你们测试吧,呵呵,SKYPE也更新试试吧。
老师帮忙看一下,如果此工具加在这个“盘符任意换”程序中
如何修改一下?
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
cls
pushd %~dp0
if %~d0 neq %systemdrive% (
if not exist %temp%\%~nx0 (
copy %0 %temp%\ /y >nul
copy fsutil.exe %temp%\ /y >nul 2>&1
copy mountvol.exe %temp%\ /y >nul 2>&1
copy more.com %temp%\ /y >nul 2>&1
pushd %temp%\
call %~nx0
exit
)
)
set ver=11-09-2012 Created by victor888.
::取得所有盘符
call :fsutil
set ALLDRV=!ALLDRV:\=!
set ALLDRV=!ALLDRV: =!
set ALLDRV=!ALLDRV::= !
::取得有装入点的盘符
FOR /F %%a in ('mountvol ^|find "\"') do set mtvdrv=!mtvdrv! %%a
::get unique drive letters which contain ":"
set mtvdrv=%mtvdrv: =%
set mtvdrv=%mtvdrv:\\?\Volume= %
set mtvdrv=%mtvdrv:}\=}%
for %%a in (%mtvdrv%) do (
for /f "delims=} tokens=1,2" %%b in ("%%a") do (
set drv=%%c
set ttmp=%%c
set ttmp=!ttmp:~-2,1!
if !ttmp! equ : set mtdrv=!mtdrv! !drv:~0,2!
)
)
if defined mtdrv (
set mtdrv=!mtdrv: =!
set mtdrv=!mtdrv::= !
)
::所有盘符-有装入点的盘符=虚拟盘符
set virdrv=%ALLDRV%
for %%a in (%mtdrv%) do (
set virdrv=!virdrv:%%a=!
)
echo.
echo 盘符随意换!ver!
echo.
:input
set drvstr=
set newdrvstr=
set olddrv=
set newdrv=
set errolddrv=
set errvirdrv=
set errnewdrv=
set leftdrv=
set oldexist=
set newexist=
set /a nn=-1
echo.
set /p drvstr=请输入原盘符及新盘符,逗号分隔成对盘符(如de,fg...,df为原盘符,eg为新盘符):
echo.
set drvstr=!drvstr:,=,!
set drvstr=!drvstr:,= !
::提取原盘符和新盘符
::盘符必须成对存在
::盘符不能是非英文字母
for %%a in (!drvstr!) do (
set eachstr=%%a
set old=!eachstr:~0,1!
set new=!eachstr:~1,1!
for %%b in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
if /i "%%b" equ "!old!" set oldexist=yes
if /i "%%b" equ "!new!" set newexist=yes
)
if "!oldexist!" neq "yes" echo 原盘符!old!不是英文字母!&goto :input
if "!newexist!" neq "yes" echo 新盘符!new!不是英文字母!&goto :input
if not defined new (
echo 与原盘符!old!匹配的新盘符不存在!
goto :input
)
set extradrv=!eachstr:~2,1!
if not defined extradrv (
set olddrv=!olddrv! !old!
set newdrv=!newdrv! !new!
set newdrvstr=!newdrvstr!,!eachstr:~0,1!-^>!eachstr:~1,1!
set /a nn+=1
) else (
echo !extradrv!为多录入内容,请重新录入!
goto :input
)
)
::系统盘符不能更换
set tmpsys=!systemdrive:~0,1!
if /i not !olddrv!==!olddrv:%tmpsys%=! (
echo 系统盘符%systemdrive%不能更换!
goto :input
)
::虚拟盘符不能更换
if defined virdrv (
for %%a in (!virdrv!) do (
if /i not !olddrv!==!olddrv:%%a=! (
set errvirdrv=!errvirdrv! %%a
)
)
)
if defined errvirdrv (
echo 虚拟盘符!errvirdrv!不能更换!
goto :input
)
::原盘符不存在
for %%a in (!olddrv!) do (
if /i !alldrv!==!alldrv:%%a=! (
set errolddrv=!errolddrv! %%a
)
)
if defined errolddrv (
echo 输入的原盘符!errolddrv! 不存在!
goto :input
)
::原盘符有重复
for %%a in (%olddrv%) do (
set /a n=0
for %%b in (%olddrv%) do (
if %%a equ %%b (
set /a n+=1
if !n! GTR 1 (
echo 原盘符"%%a"有重复,请检查!
goto :input
)
)
)
)
::新盘符有重复
for %%a in (%newdrv%) do (
set /a m=0
for %%b in (%newdrv%) do (
if %%a equ %%b (
set /a m+=1
if !m! GTR 1 (
echo 新盘符"%%a"有重复,请检查!
goto :input
)
)
)
)
::新盘符与不更换的已有盘符冲突
set leftdrv=!alldrv!
for %%a in (%olddrv%) do set leftdrv=!leftdrv:%%a=!
for %%a in (!newdrv!) do (
if /i not !leftdrv!==!leftdrv:%%a=! (
set errnewdrv=!errnewdrv! %%a
)
)
if defined errnewdrv (
echo 输入的新盘符!errnewdrv! 已经存在,请重新输入!
goto :input
)
set /p dogo=确认要进行如下调换!newdrvstr! (y/n)?
if /i !dogo! equ y (
call :mountbegin
) else (
echo 用户取消!
exit
)
if exist %temp%\mountvol.exe del %temp%\mountvol.exe
if exist %temp%\fsutil.exe del %temp%\fsutil.exe
if exist %temp%\more.com del %temp%\more.com
if exist %temp%\%~nx0 del %temp%\%~nx0
echo 更换盘符成功!
pause
goto :end
:mountbegin
for %%a in (%olddrv%) do (
mountvol %%a: /d
)
set olddrv=!olddrv: =!
set newdrv=!newdrv: =!
for /l %%a in (0,1,!nn!) do (
set old=!olddrv:~%%a,1!
set new=!newdrv:~%%a,1!
for %%b in (%mtvdrv%) do (
set amp=%%b
set vid=\\?\Volume!amp:~0,38!
set drv=!amp:~38,1!
if /i !drv!==!old! (
mountvol !new!: !vid!
)
)
)
goto :eof
:fsutil
for /f "delims=:\ " %%a in ('fsutil.exe fsinfo drives^|more') do (
set tmpdrv=%%a
if !tmpdrv:~-2! equ %%a set ALLDRV=!ALLDRV! %%a:
)
goto :eof
:end |
|