|
好吧,这个是简单的实现办法
- @echo off
- rem 获取本机启动项的GUID,即displayorder列表
- set n=1
- setlocal enabledelayedexpansion
- bcdedit /enum {bootmgr} /v >%temp%\bootlist.txt
- rem 获取displayorder所在的行号
- for /f "tokens=1 delims=:" %%a in ('type "%temp%\bootlist.txt" ^| findstr /n "^displayorder"') do set /a skip=%%a-1
- rem 忽略displayorder之前的行从而节省时间
- for /f "skip=%skip% tokens=1,2" %%a in ('type "%temp%\bootlist.txt"') do (
- if /i "%%a"=="default" set "default=%%b"
- if /i "%%a"=="displayorder" set boot-1=%%b
- echo %%a | findstr "{.*}" >nul 2>nul && (
- set /a n+=1
- set boot-!n!=%%a
- )
- )
- del /f /q "%temp%\bootlist.txt"
- :menu
- for /l %%a in (1,1,!n!) do (
- echo; [%%a] *****************************************************************
- echo;
- bcdedit /enum !boot-%%a! /v | findstr /r "!boot-%%a! device osdevice description"
- echo;
- )
- echo;
- set /p input=请选择您要删除的启动项:
- cls & bcdedit /enum !boot-%input%! /v & echo;
- echo;你确定要删除上面的启动项吗? Y 继续
- set /p ok=
- if /i not ok==y goto menu
- bcdedit /delete !boot-%input%! /cleanup /f
- pause
复制代码 |
|