5

ImageXとWIMを使用してHDDを再構築すると、BCDが破損することがあります。そのため、コマンドプロンプトで無人で実行されているスクリプトからBCDを再構築する必要があります。bcdeditを使用したスクリプト

以下のコードは、手動で入力したときのジョブです。上記始めたので、私は無人コマンドプロンプトでこれを実行する必要があり、

bootrec.exe /fixmbr 
bootsect.exe /nt60 all /force 
attrib -h -s C:\boot\BCD 
del C:\boot\BCD 
bcdedit.exe /createstore c:\boot\bcd.temp 
bcdedit.exe /store c:\boot\bcd.temp /create {bootmgr} /d "Windows Boot Manager" 
bcdedit.exe /import c:\boot\bcd.temp 
bcdedit.exe /set {bootmgr} device partition=C: 
bcdedit.exe /timeout 10 
attrib -h -s C:\boot\bcd.temp 
del c:\boot\bcd.temp 
bcdedit.exe /create /d "Microsoft Windows" /application osloader 
bcdedit.exe /set {GUID} device partition=C: 
bcdedit.exe /set {GUID} osdevice partition=C: 
bcdedit.exe /set {GUID} path \Windows\system32\winload.exe 
bcdedit.exe /set {GUID} systemroot \Windows 
bcdedit.exe /displayorder {GUID} 

:私はそれを自動化する助けを(さらにコード例下記参照)が必要です。 6番目の最後のステートメント "bcdedit.exe/create/d"の出力は、Microsoft Windowsの "/ application osloader"が新規作成のGUIDです。このIDは次のコマンドで必要です。

この新しいGUIDをbcdeditから次のコードで呼び出すことができる変数にロードするにはどうすればよいですか?

よろしく ヘンリクV.ニールセン

+0

こんにちは。私はOSがWin7 Embedded 32bitであることを忘れていました。 WinPE USBディスクからスクリプトを実行しています。 –

答えて

4

他は同じ問題に直面しなければならない場合、私は次の行を追加して、それを解決しました。

For /F "tokens=2 delims={}" %%i in ('bcdedit.exe') do (set _NEWGUID=%%i) 

これは、ファイルにGUIDが1つしかないために機能します。

0

簡単な方法があります。

新しいエントリのBCD​​を作成するフォームaaaaaaaaを-BBBB-CCCC-DDDD-eeeeeeeeeeee(桁8-4-4-4-12の数)

内のすべてのGUIDを受け付けるとこれはあなたを意味Forループを使用してGUIDを検索する必要がないGUIDを定義できます。

私のために働いています。

+0

こんにちはmr netlord、 興味深いですね。私はスクリプトを更新する必要がある次回の実装を試みます。 –

0

これは解決策であるヘンリックのコード

に基づく。これは、テキストファイルにBCDから作成されたGUIDを受け取り、forループファイル

bootrec.exe /fixmbr 
bootsect.exe /nt60 all /force 
attrib -h -s C:\boot\BCD 
del C:\boot\BCD 
bcdedit.exe /createstore c:\boot\bcd.temp 
bcdedit.exe /store c:\boot\bcd.temp /create {bootmgr} /d "Windows Boot Manager" 
bcdedit.exe /import c:\boot\bcd.temp 
bcdedit.exe /set {bootmgr} device partition=C: 
bcdedit.exe /timeout 10 
attrib -h -s C:\boot\bcd.temp 
del c:\boot\bcd.temp 
bcdedit.exe /create /d "Microsoft Windows" /application osloader>GUID.txt 
For /F "tokens=2 delims={}" %%i in (GUID.txt) do (set _NEWGUID=%%i) 
bcdedit.exe /set %_NEWGUID% device partition=C: 
bcdedit.exe /set %_NEWGUID% osdevice partition=C: 
bcdedit.exe /set %_NEWGUID% path \Windows\system32\winload.exe 
bcdedit.exe /set %_NEWGUID% systemroot \Windows 
bcdedit.exe /displayorder %_NEWGUID% 
0

ディランGrasha あなたの答えを持っているからGUIDを取得いくつかのエラーと私はそれをより完全にするためにいくつかの拡張機能を追加しました。

@Echo Off 
bootrec.exe /fixmbr 
bootsect.exe /nt60 C: /force 
attrib -h -s C:\boot\BCD 
del C:\boot\BCD 
attrib -h -s C:\boot\bcd.temp >nul 
del C:\boot\bcd.temp >nul 
bcdedit /createstore c:\boot\bcd.temp 
bcdedit.exe /store c:\boot\bcd.temp /create {bootmgr} /d "Windows Boot Manager" 
bcdedit.exe /import c:\boot\bcd.temp 
bcdedit.exe /set {bootmgr} device partition=C: 
bcdedit.exe /timeout 10 
attrib -h -s C:\boot\bcd.temp 
del c:\boot\bcd.temp 
bcdedit.exe /create /d "Microsoft Windows" /application osloader>GUID.txt 
For /F "tokens=2 delims={}" %%i in (GUID.txt) do (set _NEWGUID=%%i) 
bcdedit.exe /set {%_NEWGUID%} device partition=C: 
bcdedit.exe /set {%_NEWGUID%} osdevice partition=C: 
bcdedit.exe /set {%_NEWGUID%} path \Windows\system32\winload.exe 
bcdedit.exe /set {%_NEWGUID%} systemroot \Windows 
bcdedit.exe /displayorder {%_NEWGUID%} 
del guid.txt 
cmd 
0

BCDを簡単に固定する方法があります。

bcdboot c:\windows 

たとえば、質問のすべてのbcdeditコマンドを置き換えます。

using bcdboot to fix BCDの説明を参照してください。

ユーティリティbcdbootおよびbootsectは、すべてのブート問題(初期ブートシーケンスに関する)を修正できます。

sfc.exeは、破損したシステムファイルを修正できます。

関連する問題