Board logo

标题: [其他] 求助:把默认PE安装到容量最大的盘的批处理修改为安装到系统盘 [打印本页]

作者: hfstar    时间: 2021-8-30 14:18     标题: 求助:把默认PE安装到容量最大的盘的批处理修改为安装到系统盘

本帖最后由 hfstar 于 2021-8-30 14:21 编辑

这个批处理是把PE安装到容量最大的一个盘,如果我要把PE修改了安装在系统盘,怎么修改呢?向各位求助一下。
  1. @echo off
  2. color 3F
  3. setlocal EnableDelayedExpansion
  4. bcdedit /enum {current}|find "system32\winload.exe">nul
  5. if %errorlevel% equ 1 (
  6. set bootmode=uefi
  7. set winload=winload.efi
  8. ) else (
  9. set bootmode=bios
  10. set winload=winload.exe
  11. )
  12. for /f "tokens=1-5 delims= " %%a in ('drvtype -a ^|find ":"') do set HDDList=%%d
  13. for %%b in (!HDDList!) do (
  14. set tmpVol=%%b
  15. call :check
  16. if /i "!judge!" == "ok" (
  17. if /i "%bootmode%" == "uefi" (
  18. if exist !tmpVol!\EFI\Microsoft\Boot\BCD set efi=!tmpVol!
  19. )
  20. )
  21. set LastVol=!tmpVol!
  22. )
  23. if not "!efi!"== "" set LastVol=!efi!
  24. call :InstPE
  25. pause & exit
  26. :check
  27. for /f "tokens=1-4 delims= " %%i in ('dir %tmpVol% ^|find /i "可用字节"') do (
  28. set space=%%k
  29. )
  30. set space=!space:,=!
  31. if !space! lss 50000000 (set judge=err) else set judge=ok
  32. goto:eof
  33. :InstPE
  34. ECHO 安装PE到 %lastvol% 盘
  35. if not exist %LastVol%\BOOT md %LastVol%\BOOT
  36. copy /y .\*.wim %LastVol%\BOOT\
  37. copy /y .\BOOT.SDI %LastVol%\BOOT\
  38. del .\*.wim
  39. bcdedit.exe /timeout 9
  40. bcdedit.exe /set {current} bootmenupolicy Legacy
  41. set id1={%time:~6,2%%time:~9,2%ffff-8d96-11de-8e71-fffffffffffa}
  42. set id2={%time:~6,2%%time:~9,2%ffff-8d96-11de-8e71-fffffffffffb}
  43. bcdedit /create %id2% /d "Windows 10 PE 维护平台" /device
  44. bcdedit /set %id2% ramdisksdidevice partition=%LastVol%
  45. bcdedit /set %id2% ramdisksdipath \boot\boot.sdi
  46. bcdedit /create %id1% /d "Windows 10 PE 维护平台" /application osloader
  47. bcdedit /set %id1% device ramdisk=[%LastVol%]\boot\1064.WIM,%id2%
  48. bcdedit /set %id1% osdevice ramdisk=[%LastVol%]\boot\1064.WIM,%id2%
  49. bcdedit /set %id1% path \windows\system32\boot\%winload%
  50. bcdedit /set %id1% description "Windows 10 PE 维护平台"
  51. bcdedit /set %id1% locale zh-CN
  52. bcdedit /set %id1% inherit {bootloadersettings}
  53. bcdedit /set %id1% systemroot \windows
  54. bcdedit /set %id1% detecthal Yes
  55. bcdedit /set %id1% winpe Yes
  56. bcdedit /set %id1% ems no
  57. bcdedit /displayorder %id1% /addlast
  58. attrib +r +h +s +a %LastVol%\BOOT
  59. goto:eof
复制代码

作者: newswan    时间: 2021-8-30 14:53

本帖最后由 newswan 于 2021-8-30 19:54 编辑
  1. @echo off
  2. color 3F
  3. setlocal EnableDelayedExpansion
  4. bcdedit /enum {current}|find "system32\winload.exe">nul
  5. if %errorlevel% equ 1 (
  6. set bootmode=uefi
  7. set winload=winload.efi
  8. ) else (
  9. set bootmode=bios
  10. set winload=winload.exe
  11. )
  12. set vol=%SystemDrive%
  13. :InstPE
  14. ECHO 安装PE到 %vol% 盘
  15. if not exist %vol%\BOOT md %vol%\BOOT
  16. copy /y .\*.wim %vol%\BOOT\
  17. copy /y .\BOOT.SDI %vol%\BOOT\
  18. del .\*.wim
  19. bcdedit.exe /timeout 9
  20. bcdedit.exe /set {current} bootmenupolicy Legacy
  21. set id1={%time:~6,2%%time:~9,2%ffff-8d96-11de-8e71-fffffffffffa}
  22. set id2={%time:~6,2%%time:~9,2%ffff-8d96-11de-8e71-fffffffffffb}
  23. bcdedit /create %id2% /d "Windows 10 PE 维护平台" /device
  24. bcdedit /set %id2% ramdisksdidevice partition=%vol%
  25. bcdedit /set %id2% ramdisksdipath \boot\boot.sdi
  26. bcdedit /create %id1% /d "Windows 10 PE 维护平台" /application osloader
  27. bcdedit /set %id1% device ramdisk=[%vol%]\boot\1064.WIM,%id2%
  28. bcdedit /set %id1% osdevice ramdisk=[%vol%]\boot\1064.WIM,%id2%
  29. bcdedit /set %id1% path \windows\system32\boot\%winload%
  30. bcdedit /set %id1% description "Windows 10 PE 维护平台"
  31. bcdedit /set %id1% locale zh-CN
  32. bcdedit /set %id1% inherit {bootloadersettings}
  33. bcdedit /set %id1% systemroot \windows
  34. bcdedit /set %id1% detecthal Yes
  35. bcdedit /set %id1% winpe Yes
  36. bcdedit /set %id1% ems no
  37. bcdedit /displayorder %id1% /addlast
  38. attrib +r +h +s +a %vol%\BOOT
  39. goto:eof
复制代码

作者: hfstar    时间: 2021-8-30 15:12

回复 2# newswan


    多谢多谢!
作者: newswan    时间: 2021-8-30 19:55

先有个错误
  1. set vol=SystemDrive
复制代码
要改成
  1. set vol=%SystemDrive%
复制代码

作者: hfstar    时间: 2021-8-30 22:05

本帖最后由 hfstar 于 2021-8-30 22:09 编辑

呵呵,没事,这个我发现了,批处理的变量必须加俩英文的%%
作者: 窄口牛    时间: 2021-8-31 06:47

没必要最大的盘哇,esp分区分的大点,wim加一百兆就够了。legacy下就替换掉系统的re好了。
作者: hfstar    时间: 2021-8-31 16:26

回复 6# 窄口牛
哦哦,多谢指点




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2