set bHvSetESP=n
for %%i in (z y x w v u t s r q p o n m) do (
if !bHvSetESP!==n ( if not exist %%i: set Label_ESP=%%i&&set bHvSetESP=y )
)
echo list vol>%temp%\DiskPart.txt
echo exit>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
echo 要为某卷分配随机盘符,那我认为此卷没有盘符,如果已有,执行报错!
set /p NumVolESP=请输入要分配或卸载盘符分区的卷编号,直接回车----
set bAssign=y
set /p bAssign=请问是要分配装载盘符y还是删除盘符n,默认分配装载----
echo select vol !NumVolESP!>%temp%\DiskPart.txt
if not !bAssign!==n (
echo assign letter=!Label_ESP!>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
)
if !bAssign!==n (
echo remove>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
)