找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 18075|回复: 6

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

[复制链接]
发表于 2021-8-30 14:18:55 | 显示全部楼层 |阅读模式
本帖最后由 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

复制代码
发表于 2021-8-30 14:53:34 | 显示全部楼层
本帖最后由 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
复制代码

评分

参与人数 1技术 +1 收起 理由
hfstar + 1 热心助人。

查看全部评分

 楼主| 发表于 2021-8-30 15:12:51 | 显示全部楼层
回复 2# newswan


    多谢多谢!
发表于 2021-8-30 19:55:31 | 显示全部楼层
先有个错误
  1. set vol=SystemDrive
复制代码
要改成
  1. set vol=%SystemDrive%
复制代码
 楼主| 发表于 2021-8-30 22:05:20 | 显示全部楼层
本帖最后由 hfstar 于 2021-8-30 22:09 编辑

呵呵,没事,这个我发现了,批处理的变量必须加俩英文的%%
发表于 2021-8-31 06:47:27 | 显示全部楼层
没必要最大的盘哇,esp分区分的大点,wim加一百兆就够了。legacy下就替换掉系统的re好了。
 楼主| 发表于 2021-8-31 16:26:06 | 显示全部楼层
回复 6# 窄口牛
哦哦,多谢指点
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-21 00:42 , Processed in 0.031563 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表