
- 帖子
- 7
- 积分
- 174
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2007-12-17
|
更改驱动器号, diskpart 确实比较慢. 以前本想用 mountvol 写一个, 可惜别人早写了, 所以才写了 diskpart 的.
以下是代码:
@echo off
::asgn letter [letter|/d]
::asgn No. [letter|/d]
if "%1"=="" Type "%~f0"|findstr "^::"&&goto :eof
set usr=net user %username%
set fnd=find /i "*administrator"
%usr%|%fnd%>nul||goto chkusr
if %1 lss 9 goto cont
set drv=fsutil fsinfo drives
%drv%|find /i "%1">nul||goto error1
%drv%|find /i "%2">nul&&goto error2
:cont
set file=%tmp%\script
if "%2"=="" goto auto
if "%2"=="/d" goto delete
:assign
echo select disk 0 >%file%
echo select volume %1 >>%file%
echo assign letter=%2 >>%file%
diskpart /s %file% >nul>nul
echo 成功指派了驱动器号或装载点
del %file%
goto :eof
:auto
echo select disk 0 >%file%
echo select volume %1 >>%file%
echo assign >>%file%
diskpart /s %file%>nul
echo 成功指派了驱动器号或装载点
del %file%
goto :eof
:delete
echo select disk 0 >%file%
echo select volume %1 >>%file%
echo remove >>%file%
diskpart /s %file%>nul
echo 成功删除了驱动器号或装载点
del %file%
goto :eof
:error1
echo 指定的驱动器不存在
goto :eof
:error2
echo 目标驱动器已存在
goto :eof
:chkusr
echo 没有管理特权
echo. |
|