利用脚本修复WINDOWS引导文件丢失

     引导文件丢失,即系统目录下Boot目录及Bootmgr丢失,一般的解决方案有如下两种:

1. 进WINPE系统进行修复。

2. 利用bootbcd修复,bootbcd c:\Windows /s c:。

第二种方法可能会报错:BFSVC: Failed to set element application device. Status = [c00000bb],此时可以用如下的脚本进行修复。

如将该脚本保存为test.bat,需要修复的盘为z盘,运行命令test.bat z即可。

::@echo off

::make sure have one parameter
if [%1] == [] exit 1

::create environment
bcdboot %1:\Windows /s %1:
del %1:\Boot\BCD

::create BCD File
bcdedit.exe /createstore %1:\Boot\BCD

::create bootmgr
bcdedit.exe /store %1:\Boot\BCD /create {bootmgr} /d "Winodws Boot Manager"
bcdedit.exe /store %1:\Boot\BCD /set {bootmgr} device partition=C:

::get device key
for /f "delims=" %%i in ('bcdedit.exe /store %1:\Boot\BCD /create /d "Windows7" /application osloader') do (
	set DeviceKey=%%i	
)

set DeviceKey=%DeviceKey:~2,38%
echo %DeviceKey%

::set BCD 
bcdedit.exe /store %1:\Boot\BCD /set %DeviceKey% device partition=C: 
bcdedit.exe /store %1:\Boot\BCD /set %DeviceKey% osdevice partition=C:
bcdedit.exe /store %1:\Boot\BCD /set %DeviceKey% path \Windows\system32\winload.exe
bcdedit.exe /store %1:\Boot\BCD /set %DeviceKey% systemroot \Windows
bcdedit.exe /store %1:\Boot\BCD /displayorder %DeviceKey%
bcdedit.exe /store %1:\Boot\BCD /default %DeviceKey%

::avoid winload.exe error 
bcdedit.exe /store %1:\Boot\BCD /set {default} osdevice boot
bcdedit.exe /store %1:\Boot\BCD /set {default} device boot
bcdedit.exe /store %1:\Boot\BCD /set {default} detecthal 1


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值