标题: [系统相关] [已解决]bat命令搭配bcdedit,如何添加/删除/修改win7 64系统的启动菜单项目? [打印本页]
作者: ygqiang 时间: 2015-1-19 18:34 标题: [已解决]bat命令搭配bcdedit,如何添加/删除/修改win7 64系统的启动菜单项目?
[已解决]bat命令搭配bcdedit,如何添加/删除/修改win7 64系统的启动菜单项目?- set "bcdedit=%SystemRoot%\System32\bcdedit.exe"
-
- %bcdedit% /create {ntldr} /d "通用PE工具箱2"
- %bcdedit% /set {ntldr} device partition=C:
- %bcdedit% /set {ntldr} path \8888\ABSPE
- %bcdedit% /set {ntldr} inherit {bootloadersettings}
- %bcdedit% /set {ntldr} locale zh-CN
- %bcdedit% /displayorder {ntldr} /addfirst
复制代码
这个命令,生成的启动项目是:0.jpg照片截图。
某个pe.exe软件,在win7 64系统下安装完以后,会生成启动菜单项目是:1.jpg照片截图。
bat命令搭配bcdedit,如何添加/删除/修改类似pe.exe软件生成的启动菜单项目?
作者: ygqiang 时间: 2015-1-19 19:16
本帖最后由 ygqiang 于 2015-1-20 07:54 编辑
- set "bcdedit=%SystemRoot%\System32\bcdedit.exe"
- %bcdedit% /enum >>list.txt
复制代码
生成list.txt文件内容如下:- Windows 启动管理器
- --------------------
- 标识符 {bootmgr}
- device partition=C:
- description Windows Boot Manager
- locale en-us
- inherit {globalsettings}
- default {current}
- resumeobject {b562ed91-5fbd-11e2-bdba-b9260cd4d68b}
- displayorder {ntldr}
- {current}
- {777778af-66c9-4ad4-a54e-d76256db09e1}
- toolsdisplayorder {memdiag}
- timeout 3
-
- Windows 旧 OS 加载器
- ------------------------
- 标识符 {ntldr}
- device partition=C:
- path \8888\ABSPE
- description 通用PE工具箱2
- locale zh-CN
- inherit {bootloadersettings}
-
- Windows 启动加载器
- -------------------
- 标识符 {current}
- device partition=C:
- path \windows\system32\winload.exe
- description Windows 7
- locale en-us
- inherit {bootloadersettings}
- testsigning Yes
- osdevice partition=C:
- systemroot \windows
- resumeobject {b562ed91-5fbd-11e2-bdba-b9260cd4d68b}
- nx OptIn
- detecthal Yes
-
- 实模式启动扇区
- ---------------------
- 标识符 {777778af-66c9-4ad4-a54e-d76256db09e1}
- device partition=C:
- path \8888\PELOAD
- description 通用 PE 工具箱5.0
复制代码
Windows 旧 OS 加载器
实模式启动扇区
这2个项目,通过bat命令搭配bcdedit,如何删除?删除以后,如何重新建立“实模式启动扇区”这个项目?
作者: yiwuyun 时间: 2015-1-20 08:41
bcdedit /delete {ntldr}
bcdedit /delete {777778af-66c9-4ad4-a54e-d76256db09e1}
bcdedit /create {ntldr}
bcdedit /create {777778af-66c9-4ad4-a54e-d76256db09e1} /application bootsector
作者: ygqiang 时间: 2015-1-20 08:57
bcdedit /delete {ntldr}
bcdedit /delete {777778af-66c9-4ad4-a54e-d76256db09e1}
bcdedit /create ...
yiwuyun 发表于 2015-1-20 08:41
多谢。。。- set "bcdedit=%SystemRoot%\System32\bcdedit.exe"
-
- %bcdedit% /create {777778af-66c9-4ad4-a54e-d76256db09e1} /application bootsector
- %bcdedit% /create {777778af-66c9-4ad4-a54e-d76256db09e1} /d "通用PE工具箱9"
- %bcdedit% /set {777778af-66c9-4ad4-a54e-d76256db09e1} device partition=C:
- %bcdedit% /set {777778af-66c9-4ad4-a54e-d76256db09e1} path \8888\PELOAD
- %bcdedit% /displayorder {777778af-66c9-4ad4-a54e-d76256db09e1} /addlast
复制代码
这个命令,生成如下菜单:
实模式启动扇区
---------------------
标识符 {777778af-66c9-4ad4-a54e-d76256db09e1}
device partition=C:
path \8888\PELOAD
如何修改,才能生成下面这种菜单?
作者: ygqiang 时间: 2015-1-20 09:02
bcdedit /delete {ntldr}
bcdedit /delete {777778af-66c9-4ad4-a54e-d76256db09e1}
bcdedit /create ...
yiwuyun 发表于 2015-1-20 08:41
搞定了。。。多谢。。- %bcdedit% /create {777778af-66c9-4ad4-a54e-d76256db09e1} /application bootsector /d "通用PE工具箱5.0"
- %bcdedit% /set {777778af-66c9-4ad4-a54e-d76256db09e1} device partition=C:
- %bcdedit% /set {777778af-66c9-4ad4-a54e-d76256db09e1} path \8888\PELOAD
- %bcdedit% /displayorder {777778af-66c9-4ad4-a54e-d76256db09e1} /addlast
复制代码
作者: ygqiang 时间: 2015-1-20 13:18
初步解决了。- :通用PE工具箱5.0-win7-64
- setlocal enabledelayedexpansion
-
- set tim=3
- set descri="通用PE工具箱5.0"
- set "bcdedit=%SystemRoot%\System32\bcdedit.exe"
- set "rar=C:\Program Files (x86)\WinRAR\WinRAR.exe"
-
- if not exist c:\8888 "%rar%" x -y "通用PE工具箱5.0.rar" c:\
-
- echo %bcdedit%
- 1%bcdedit% /v >list.txt
- 1%bcdedit% /enum >list.txt
-
- %bcdedit% /timeout %tim%
-
- set "strID="
- for /f "tokens=1,2* delims=: " %%i in ('findstr /n /r "通用.*PE" list.txt') do (
- echo,当前发现符合条件描述在 : %%i 行
- set /a "desLine=%%i"
- echo,完整描述内容为 : %%k
- echo,&echo,
-
- echo,从描述行前推4行,作为more的传入参数,作单循环处理便可查询当前节点的标识符
- set /a "desLine-=4"
- if !desLine! LSS 0 set /a "desLine=0"
-
- for /f "tokens=1,*" %%a in ('more +!desLine! list.txt^|findstr /i /r "标识符"') do (
- echo,查询当前节点的标识符为 : %%b
- set "strID=%%b"
- goto :next
- )
- )
- :next
- echo,现在你已经得到标识符了,它存于变量strID里面,如果为空,则无符合条件
- echo,strID值 : !strID!
-
-
-
-
- if "!strID!" EQU "" goto :creatt
-
-
- %bcdedit% /delete !strID!
- 1%bcdedit% /enum >list.txt
-
-
- :creatt
-
- %bcdedit% /create {777778af-66c9-4ad4-a54e-d76256db09e1} /application bootsector /d %descri%
- %bcdedit% /set {777778af-66c9-4ad4-a54e-d76256db09e1} device partition=C:
- %bcdedit% /set {777778af-66c9-4ad4-a54e-d76256db09e1} path \8888\PELOAD
- %bcdedit% /displayorder {777778af-66c9-4ad4-a54e-d76256db09e1} /addlast
-
- 1%bcdedit% /enum >list2.txt
-
- cls
- ping 127.0.0.1 -n 1 >nul 2>nul
- del /f /q list*.txt
-
- 1pause&goto :EOF
复制代码
作者: ygqiang 时间: 2015-1-20 13:48
本帖最后由 ygqiang 于 2015-1-20 21:39 编辑
- :通用PE工具箱5.0-win7-64
- setlocal enabledelayedexpansion
-
- set tim=3
- set descri="通用PE工具箱5.0"
- set "bcdedit=%SystemRoot%\System32\bcdedit.exe"
- set "rar=C:\Program Files (x86)\WinRAR\WinRAR.exe"
-
- if not exist c:\8888 "%rar%" x -y "通用PE工具箱5.0.rar" c:\
-
- echo %bcdedit%
- %bcdedit% /v >list.txt
- %bcdedit% /enum >list1.txt
-
- %bcdedit% /timeout %tim%
-
-
-
-
- echo,赋值初始行指针
- set /a "nLine=0"
- echo,&echo,
-
- echo,查找符合条件总共有多少个节点
- set /a "nCount=0"
- for /f "delims=" %%i in ('findstr /i /r "通用.*PE" list.txt') do set /a "nCount+=1"
- echo,总共有 !nCount! 个节点符合要求
- echo,&echo,
-
- echo,设置查找次数标记
- set /a "nIndex=0"
- echo,&echo,
-
- :_start
- set /a "nIndex+=1"
- set "strID!nIndex!="
- for /f "tokens=1,2* delims=: " %%i in ('^(more +!nLine! list.txt^) ^| findstr /n /r "通用.*PE"') do (
- set /a "desLine=nLine+%%i"
- echo,当前发现符合条件描述在 : !desLine! 行
- set /a "nLine=desLine"
- echo,查到目标,更新行指针为 : !nLine!
- echo,完整描述内容为 : %%k
- echo,&echo,
-
- echo,从描述行前推4行,作为more的传入参数,作单循环处理便可查询当前节点的标识符
- set /a "desLine-=4"
- if !desLine! LSS 0 set /a "desLine=0"
-
- for /f "tokens=1,*" %%a in ('^(more +!desLine! list.txt^)^|findstr /i /r "标识符"') do (
- echo,查询当前节点的标识符为 : %%b
- set "strID!nIndex!=%%b"
- goto :next
- )
- )
- :next
- if !nIndex! LEQ !nCount! (
- echo,现在你已经得到标识符了,它存于变量strID!nIndex!里面,如果为空,则无符合条件
- call echo,strID!nIndex!值 : %%strID!nIndex!%%
- echo,==========================================&echo,&echo,
-
- REM 做你要做的事情
- REM Code here...
- REM 要做的事情结束
- call %bcdedit% /delete %%strID!nIndex!%%
-
- set /a "nLine+=1"
- echo,现在将行指针下移一行,继续开始查找符合条件项
- echo,新的行指针为 : !nLine!
- )
-
- if !nIndex! LEQ !nCount! goto :_start
-
-
-
-
-
- %bcdedit% /v >list2.txt
-
-
- :creatt
-
- %bcdedit% /create {777778af-66c9-4ad4-a54e-d76256db09e1} /application bootsector /d %descri%
- %bcdedit% /set {777778af-66c9-4ad4-a54e-d76256db09e1} device partition=C:
- %bcdedit% /set {777778af-66c9-4ad4-a54e-d76256db09e1} path \8888\PELOAD
- %bcdedit% /displayorder {777778af-66c9-4ad4-a54e-d76256db09e1} /addlast
-
- %bcdedit% /v >list3.txt
-
- cls
- ping 127.0.0.1 -n 1 >nul 2>nul
- del /f /q list*.txt
-
- 1pause&goto :EOF
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |