@echo off
echo 正在挂载ESP分区……
FOR /F "usebackq tokens=2 delims= " %%i in (` echo list disk ^|diskpart ^| find "磁盘" `) do (
echo select disk=%%i>%temp%\t.txt
echo list partition>>%temp%\t.txt
FOR /F "usebackq tokens=2 delims= " %%j in (` diskpart /s %temp%\t.txt ^| find "系统" `) do (
echo select disk=%%i>%temp%\t.txt
echo select partition=%%j>>%temp%\t.txt
echo assign>>%temp%\t.txt
diskpart /s %temp%\t.txt>nul
) )
echo;
echo; 1.请按下任意键来打开Diskgeniu-s以查看ESP分区所挂载的盘符,按下后请
echo;
echo;先耐心地等待几秒钟来等候Diskgeniu-s窗口的打开。
echo;
pause
@if not exist "%programw6432%" (call 运行U盘里32位的DG分区.bat) else call 运行U盘里64位的DG分区.bat
echo;
echo; 2.请再按下任意键来打开PE的“计算机窗口”以查看ESP分区......
echo;
pause
start "" ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
exit
用这个“挂载ESP分区.bat(——nttwqz网友原创,我只是略作改动)”也行:
@echo off
title 查找活动分区及ESP分区
rem 需要diskpart支持
rem 自动请求以管理员权限运行
set vbs="%temp%\getadmin.vbs"
reg query HKU\S-1-5-20>nul 2>nul || echo CreateObject^("Shell.Application"^).ShellExecute "%~f0", "%*", "", "runas", 1 > %vbs% && cscript //b %vbs% && exit /b & del %vbs% /f /q>nul 2>nul
::设置是否为无盘符的活动分区或EFI分区分配盘符(一般重启会消失),开启:y
set auto=y
setlocal enabledelayedexpansion
echo;正在处理,请稍候...
rem 列表磁盘并判断是否是GPT磁盘
set dptmp="%temp%\diskpart.tmp"
echo list disk | diskpart >%dptmp%
set n=0
for /f "tokens=2,3*" %%a in ('type %dptmp% ^| find /i "B "') do (
set /a n+=1
set disk-!n!=%%a
rem 判断是否是GPT磁盘
set "var=%%b%%c"
set "var=!var:~-1!
if "!var!"=="*" (set "gpt-!n!=Yes") else (set "gpt-!n!=No")
)
for /l %%a in (1,1,!n!) do (
rem 判断GPT磁盘的ESP分区
if /i "!gpt-%%a!"=="yes" (
for /f "tokens=2" %%b in ('(echo sel disk !disk-%%a! ^&^& echo list part^) ^| diskpart ^| find /i"B "') do (
if not defined boot-%%a call :findbootpartition %%a %%b "c12a7328-f81f-11d2-ba4b-00a0c93ec93b"
)
) else (
rem 判断MBR磁盘的活动分区
for /f "tokens=2" %%c in ('(echo sel disk !disk-%%a! ^&^& echo list part^) ^| diskpart ^| find /i"B " ^| find /i /v "扩展的" ^| find /i /v "逻辑"') do (
if not defined boot-%%a call :findbootpartition %%a %%c "活动: 是"
)
)
rem 确定ESP分区及活动分区盘符
if not "!boot-%%a!"=="未找到" (
(echo sel disk !disk-%%a!
echo sel part !boot-%%a!
echo detail part)>%dptmp%
for /f "tokens=4" %%d in ('diskpart /s %dptmp% ^| find "*"') do (
if exist "%%d:\" (set "ltr-%%a=%%d:") else (
set "ltr-%%a=无盘符"
rem 当变量auto值为y时自动分配盘符
if /i "%auto%"=="y" (
(echo sel disk !disk-%%a!
echo sel part !boot-%%a!
echo assign
echo detail part)>"%temp%\diskpart-ltr.tmp"
for /f "tokens=4" %%e in ('diskpart /s "%temp%\diskpart-ltr.tmp" ^| find "*"') do (
if exist "%%e:\" (set "ltr-%%a=%%e:") else (set "ltr-%%a=无法分配")
)
)
)
)
)
)
rem 清理临时文件
del /f /q %dptmp% >nul 2>nul
del /f /q "%temp%\diskpart-ltr.tmp" >nul 2>nul
cls
echo;序号 磁盘 分区 盘符 GPT
echo;------------------------------------------
for /l %%a in (1,1,!n!) do if not "!boot-%%a!"=="未找到" echo;%%a. !disk-%%a! !boot-%%a! !ltr-%%a! !gpt-%%a!
echo;
echo; 请耐心等待一会儿,等看清ESP分区的盘符后再按下任意键打开“计算机
echo;
echo;窗口”查看ESP分区。
echo;
pause
start "" ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
echo;
echo; 最后请按下任意键退出CMD程序。
echo;
pause
:findbootpartition
(echo sel disk !disk-%1!
echo sel part %2
echo detail part)>%dptmp%
diskpart /s %dptmp% | find /i "%~3" >nul 2>&1
if !errorlevel!==0 (set "boot-%1=%2") else (set "boot-%1=未找到")
goto :eof
FOR /F "usebackq tokens=2 delims= " %%i in (` echo list disk ^|diskpart ^| find "磁盘" `) do (
echo select disk=%%i>%temp%\t.txt
echo list partition>>%temp%\t.txt
FOR /
详情回复
发表于 2017-12-24 14:26