|
本帖最后由 nttwqz 于 2017-11-21 00:03 编辑
重新写了一个,需要PE支持wmic,安装光盘中的boot.wim内置,8.1正常系统中测试通过。
查找活动及EFI分区_wmic.7z
(1.14 KB, 下载次数: 15)
源代码(粘贴进来的,不保证正常运行,强烈建议下载附件)
- @echo off
- title 查找活动分区及EFI分区
- rem 需要wmic支持,经测试Windows 7安装光盘boot.wim内置
- rem 自动请求以管理员权限运行
- reg query HKU\S-1-5-20>nul 2>nul || echo CreateObject^("Shell.Application"^).ShellExecute "%~f0", "", "", "runas", 1 > "%temp%\getadmin.vbs" && cscript //b "%temp%\getadmin.vbs" && exit /b & del "%temp%\getadmin.vbs" /f /q>nul 2>nul
- rem 系统版本号判断
- for /f "tokens=2 delims=[" %%Q in ('ver') do for /f "tokens=2,3 delims=. " %%R in ("%%Q") do set ver=%%R%%S
- if %ver% lss 61 echo 应该仅支持Win7以上系统&&pause>nul&&exit
- ::设置是否为无盘符的活动分区或EFI分区临时分配盘符(重启后消失),开启:y
- set auto=
- setlocal enabledelayedexpansion
- echo;正在处理,请稍候...
- set n=0
- for /f "skip=1 tokens=2,3 delims=," %%a in ('wmic partition where "bootpartition='true'" get diskindex^,index /format:csv ^| findstr .') do (
- set /a n+=1
- set disk-!n!=%%a
- set /a var=%%b+1
- set index-!n!=!var!
- )
- for /l %%a in (1,1,!n!) do (
- rem 确定EFI及活动分区盘符
- (echo sel disk !disk-%%a!
- echo sel part !index-%%a!
- echo detail part)>"%temp%\diskpart-%%a.tmp"
- for /f "tokens=4" %%b in ('diskpart /s "%temp%\diskpart-%%a.tmp" ^| findstr /r "^\*"') do (
- if exist "%%b:" (set "ltr-%%a=%%b:") else (
- set "ltr-%%a=无盘符"
- rem 当变量auto值为y时自动分配盘符
- if /i "%auto%"=="y" (
- (echo sel disk !disk-%%a!
- echo sel part !index-%%a!
- echo assign
- echo detail part)>"%temp%\dpas-%%a.tmp"
- for /f "tokens=4" %%c in ('diskpart /s "%temp%\dpas-%%a.tmp" ^| findstr /r "^\*"') do (
- if exist "%%c:" (set "ltr-%%a=%%c:") else (set "ltr-%%c=无法分配")
- )
- )
- )
- )
- rem 清理临时文件
- del /f /q "%temp%\diskpart-%%a.tmp" >nul 2>nul
- del /f /q "%temp%\dpas-%%a.tmp" >nul 2>nul
- )
- cls
- echo;序号 磁盘 分区 盘符
- echo;--------------------------------
- for /l %%a in (1,1,!n!) do (
- echo;%%a. !disk-%%a! !index-%%a! !ltr-%%a!
- )
- echo;
- echo;请选择(序号):
- set /p part=
- echo;
- echo;你选择了:
- echo;
- echo;序号 磁盘 分区 盘符
- echo;--------------------------------
- echo;%part%. !disk-%part%! !index-%part%! !ltr-%part%!
- echo;
- pause
- exit
复制代码 |
|