无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 3060|回复: 6
打印 上一主题 下一主题

[求助] pe命令行自动部署系统

[复制链接]
跳转到指定楼层
1#
发表于 2017-9-12 10:00:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
想要pe命令行自动部署系统,网上找的两个批处理,怎么用不了
要改哪里,请大侠们赐教
Main.cmd

以下为Main.cmd脚本内容
@ECHO off  
@REM  This script is called by x:\Windows\System32\Startnet.cmd - WinPE  
@ECHO.  
@ECHO.  
@ECHO.  
@ECHO Running Intel Optimization powercfg for improved imaging times  
@ECHO.  
@ECHO.  
@REM  *****************************************************************  
@REM  List all the disks, then search the volumes of each one to see   
@REM  which disks may have "Winpe" in the label. We will ignore that   
@REM  disk and use the first disk without the Winpe label that we find.   
@REM  *****************************************************************  
@REM  create diskpart script for list disk  
@ECHO.>x:\listdisk.txt  
@ECHO list disk>>x:\listdisk.txt  
@ECHO exit>>x:\listdisk.txt  
@ECHO x:\listdisk.txt  
@ECHO call diskpart /s x:\listdisk.txt  
CALL diskpart /s x:\listdisk.txt>x:\Disks.txt  
@ECHO.  
@REM Set Disk equal to blank to start  
SET disk=  
@ECHO.  
@REM   
@REM  This line will write a diskpart script to select the disk and detail it's contents.  
@REM  We use this output to find a disk that does NOT have Winpe as the volume label.  
@REM  That disk will have the OS installed to it. This way you can exclude USB from diskpart.  
@REM   
@REM  This works around the issue where the USB key is sometimes enumerated as disk 0 and the   
@REM  SSD is disk 1.   
@REM  依次取磁盘0,1,2,。。。,1.如果盘符不是WINPE设置disk的值;2.如果不是WINPE又没有磁盘,设置disk=0,后面又要讨论disk 0是否为U盘,为U盘error   
FOR /f "skip=8 tokens=2" %%A IN (x:\Disks.txt) DO (  
@ECHO sel disk %%A>x:\Par.txt  
@ECHO det disk>>x:\Par.txt  
@ECHO exit>>x:\Par.txt  
IF NOT "%%A"=="DiskPart..." CALL :LISTPAR %%A  
)  
IF "%Disk%"=="" ECHO "No disk found without a volume label of WINPE" && SET disk=0  
@rem IF "%Disk%"=="" ECHO "No disk found without a volume label of WINPE" && GOTO :ERROR  
@ECHO Using Disk "%Disk%"  
@ECHO.  
  
@rem if disk  is removable, case 1 no disk,case 2 the removable device name is not winPE  
@ECHO sel disk %Disk% >x:\Par_1.txt  
@ECHO det disk>>x:\Par_1.txt  
@ECHO exit>>x:\Par_1.txt  
CALL DISKPART /S X:\Par_1.txt>X:\ParOutput_1.txt  
FOR /f "skip=26 tokens=6" %%A IN (x:\ParOutput_1.txt) DO (  
IF /i  "%%A"=="removable"  ECHO Disk "%Disk%" is removable device GOTO :ERROR && GOTO :ERROR  
)  
  
  
  
  
@ECHO.  
@ECHO.  
@REM  *****************************************************************  
@REM    Detect if System is booted into UEFI mode or Bios mode   
@REM  *****************************************************************  
FOR /f "tokens=2* delims= " %%A IN ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B  
@ECHO.  
IF %Firmware%==0x1 GOTO :BIOSMODE  
IF %Firmware%==0x2 GOTO :UEFIMODE  
GOTO :END  
  
  
:UEFIMODE  
@ECHO.  
@REM ************************  
@REM UEFI SECTION  
@REM ************************  
@ECHO The PC is booted in UEFI mode  
@ECHO.>x:\winpart.txt  
@ECHO select disk "%Disk%">>x:\winpart.txt  
@ECHO clean>>x:\winpart.txt  
@ECHO convert gpt>>x:\winpart.txt  
@ECHO create partition primary size=300>>x:\winpart.txt  
@ECHO format quick fs=ntfs label="Windows RE tools">>x:\winpart.txt  
@ECHO assign letter="T">>x:\winpart.txt  
@ECHO set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\winpart.txt  
@ECHO gpt attributes=0x8000000000000001>>x:\winpart.txt  
@ECHO create partition efi size=100>>x:\winpart.txt  
@ECHO format quick fs=fat32 label="System">>x:\winpart.txt  
@ECHO assign letter="S">>x:\winpart.txt  
rem @ECHO create partition msr size=128>>x:\winpart.txt  
@ECHO create partition primary>>x:\winpart.txt  
rem @ECHO shrink minimum=15000>>x:\winpart.txt  
@ECHO format quick fs=ntfs label="Windows">>x:\winpart.txt  
@ECHO assign letter="C">>x:\winpart.txt  
  
rem @ECHO create partition primary>>x:\winpart.txt  
rem @ECHO format quick fs=ntfs label="Recovery image">>x:\winpart.txt  
rem @ECHO assign letter="R">>x:\winpart.txt  
rem @ECHO set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\winpart.txt  
rem @ECHO gpt attributes=0x8000000000000001>>x:\winpart.txt  
@ECHO list partition>>x:\winpart.txt  
@ECHO list volume>>x:\winpart.txt  
@ECHO exit>>x:\winpart.txt  
@ECHO.  
@REM *****************************************************************  
@REM  Map drive letter for Install.wim  
@REM *****************************************************************  
@ECHO.>x:\ListVol.txt  
@ECHO List volume>>x:\ListVol.txt  
@ECHO exit>>x:\ListVol.txt  
@ECHO call diskpart /s x:\ListVol.txt  
CALL DISKPART /s x:\ListVol.txt>x:\Output.txt  
@ECHO.  
@ECHO.  
@REM Go through each drive letter, looking for the \Scripts\Main.cmd file  
FOR /f "skip=8 tokens=3" %%A IN (x:\Output.txt) DO (  
IF EXIST %%A:\Scripts\Main.cmd SET InstallPath=%%A&& ECHO "Found device with images folder and Main.cmd file"  
)  
  
@ECHO call diskpart /s x:\winpart.txt  
DISKPART /s x:\winpart.txt  
  
rem == Apply the image to the Windows partition ==  
dism /Apply-Image /ImageFile:"%InstallPath%:\Scripts\install_win8_1_x64_UEFI_CN.wim" /Index:1 /ApplyDir:C:\  
rem == Copy boot files to the System partition ==  
C:\Windows\System32\bcdboot C:\Windows  
  
  
rem @ECHO copy %InstallPath%:\Scripts\ApplyImage-UEFI.bat %cd%  
rem copy %InstallPath%:\Scripts\ApplyImage-UEFI.bat %cd%  
  
rem @ECHO ApplyImage-UEFI.bat %InstallPath%:\Scripts\install.wim  
rem ApplyImage-UEFI.bat %InstallPath%:\Scripts\install.wim  
  
  
  
GOTO :WINPARTSECTION  
  
  
:BIOSMODE  
@REM ************************  
@REM BIOS SECTION  
@REM ************************  
@ECHO The PC is booted in BIOS mode  
@ECHO The PC is booted in BIOS mode>x:\Bios.txt  
@ECHO.>x:\winpart.txt  
@ECHO select disk "%Disk%">>x:\winpart.txt  
@ECHO clean>>x:\winpart.txt  
@ECHO create partition primary size=100>>x:\winpart.txt  
@ECHO active>>x:\winpart.txt  
@ECHO format quick fs=fat32 label="System">>x:\winpart.txt  
@ECHO assign letter="S">>x:\winpart.txt  
@ECHO create partition primary>>x:\winpart.txt  
@ECHO format quick fs=ntfs label="Windows">>x:\winpart.txt  
@ECHO assign letter="C">>x:\winpart.txt  
rem @ECHO shrink desired=15000>>x:\winpart.txt  
rem @ECHO create partition primary>>x:\winpart.txt  
rem @ECHO format quick fs=ntfs label="Recovery image">>x:\winpart.txt  
rem @ECHO assign letter="R">>x:\winpart.txt  
rem @ECHO set id=27>>x:\winpart.txt  
@ECHO list partition>>x:\winpart.txt  
@ECHO list volume>>x:\winpart.txt  
@ECHO exit>>x:\winpart.txt  
@ECHO.  
@REM *****************************************************************  
@REM  Map drive letter for Install.wim  
@REM *****************************************************************  
@ECHO.>x:\ListVol.txt  
@ECHO List volume>>x:\ListVol.txt  
@ECHO exit>>x:\ListVol.txt  
@ECHO call diskpart /s x:\ListVol.txt  
CALL DISKPART /s x:\ListVol.txt>x:\Output.txt  
@ECHO.  
@ECHO.  
@REM Go through each drive letter, looking for the \Scripts\Main.cmd file  
FOR /f "skip=8 tokens=3" %%A IN (x:\Output.txt) DO (  
IF EXIST %%A:\Scripts\Main.cmd SET InstallPath=%%A&& ECHO "Found device with images folder and Main.cmd file"  
)  
  
@ECHO call diskpart /s x:\winpart.txt  
DISKPART /s x:\winpart.txt  
  
rem == Apply the image to the Windows partition ==  
dism /Apply-Image /ImageFile:"%InstallPath%:\Scripts\install_win7_x64_legacy_CN.wim" /Index:1 /ApplyDir:C:\  
rem == Copy boot files to the System partition ==  
C:\Windows\System32\bcdboot C:\Windows  
  
rem @ECHO copy %InstallPath%:\Scripts\ApplyImage-BIOS.bat %cd%  
rem copy %InstallPath%:\Scripts\ApplyImage-BIOS.bat %cd%  
  
rem @ECHO ApplyImage-BIOS.bat %InstallPath%:\Scripts\install.wim  
rem ApplyImage-BIOS.bat %InstallPath%:\Scripts\install.wim  
  
GOTO :WINPARTSECTION  
  
  
:WINPARTSECTION  
  
  
  
  
  
  
@ECHO *****************************************************************  
@ECHO  Image deployment COMPLETE. Type EXIT from Command  
@ECHO *****************************************************************  
@ECHO.  
GOTO :REBOOT  
  
  
:LISTPAR  
@REM This section is to bring a disk number and use it to List Partitions  
@ECHO.  
SET TempDisk=%1  
DISKPART /s x:\Par.txt>x:\ParOutput.txt  
FOR /f "skip=26 tokens=4" %%A IN (x:\ParOutput.txt) DO (  
IF /i NOT "%%A"=="Winpe" SET Disk=%TempDisk%  
)  
GOTO :EOF  
  
:REBOOT  
@REM   
@REM  Get finish time so we can evaluate total WinPE phase time.  
@REM  
CALL |time>x:\StopTime.txt  
@ECHO.  
@ECHO Deployment complete, system restart.  
pause  
WPEUTIL REBOOT  
@ECHO.  
  
:ERROR  
@ECHO.  
@ECHO An error has been detected.  
COLOR 4F  
@ECHO.   
GOTO :END  
  
:END  
@REM   
@REM  Get finish time so we can evaluate total WinPE phase time.  
@REM  
CALL |time>x:\StopTime.txt  
@ECHO.  
FOR /f "tokens=5" %%A IN (x:\starttime.txt) DO ECHO Script Start Time is %%A  
FOR /f "tokens=5" %%A IN (x:\stoptime.txt) DO ECHO  Script Stop Time is %%A  
@ECHO.  


main.cmd结束


startnet.cmd脚本内容如下

@ECHO off  
@REM   
@REM Initialize WinPE  
@ECHO wpeinit  
WPEINIT  
@ECHO.  
@ECHO *****************************************************************  
@ECHO call wpeutil UpdateBootInfo  
WPEUTIL UpdateBootInfo  
@ECHO.  
SET WinPEREG="HKLM\System\CurrentControlSet\Control"  
SET WinPEKey=PEBootRamdiskSourceDrive  
SET WinPESource=  
@ECHO.  
@REM Get volume letter of USB Key  
@ECHO for /f "skip=2 tokens=3" %%A in ('call Reg query %WinPEREG% /v %WinPEKEY%') do set WinPESource=%%A  
FOR /f "skip=2 tokens=3" %%A IN ('call Reg query %WinPEREG% /v %WinPEKEY%') DO SET WinPESource=%%A  
@ECHO WinPESource is drive letter "%WinPESource%"  
@ECHO.  
@ECHO.  
IF "%WinPESource%"=="" ECHO Drive letter NOT found.&& CALL :FINDDRIVE  
@ECHO.  
@ECHO.  
ECHO WinPESource is "%WinPESource%"  
@ECHO.  
@ECHO *****************************************************************  
@ECHO  Call and run main.cmd on the USB Key  
@ECHO *****************************************************************  
@ECHO call %WinPESource%Scripts\main.cmd  
CALL %WinPESource%Scripts\main.cmd  
@ECHO.  
GOTO :END  
  
:ERROR  
@ECHO.  
@ECHO An error has been detected.  
COLOR 4F  
@ECHO.   
GOTO :END  
  
:FINDDRIVE  
@ECHO.  
@ECHO Trying to find drive letter using diskpart  
@ECHO.  
@ECHO Lis Vol>x:\FindVol.txt  
@ECHO.  
@ECHO Running Diskpart to get Volume letters  
@ECHO.  
DISKPART /s x:\FindVol.txt>x:\VolumeList.txt  
@ECHO.  
@ECHO Parsing list to find WinPE  
@ECHO.  
FOR /f "skip=8 tokens=3-4" %%A IN (x:\VolumeList.txt) DO (  
@ECHO Checking drive letter %%A has volume label of %%B  
IF /i "%%B"=="WINPE" SET WinPESource=%%A  
)  
SET WinPESource=%WinPESource%:\  
GOTO :EOF  
  
:END

2#
 楼主| 发表于 2017-9-13 08:00:18 来自手机 | 只看该作者
顶起来了
回复

使用道具 举报

3#
 楼主| 发表于 2017-9-14 12:24:49 来自手机 | 只看该作者
顶起来了
回复

使用道具 举报

4#
 楼主| 发表于 2017-9-15 21:37:39 来自手机 | 只看该作者
自己调试好了
回复

使用道具 举报

5#
发表于 2017-9-29 11:16:03 | 只看该作者
  1. @ECHO off  
  2. @REM  This script is called by x:\Windows\System32\Startnet.cmd - WinPE  
  3. @ECHO.  
  4. @ECHO.  
  5. @ECHO.  
  6. @ECHO Running Intel Optimization powercfg for improved imaging times  
  7. @ECHO.  
  8. @ECHO.  
  9. @REM  *****************************************************************  
  10. @REM  List all the disks, then search the volumes of each one to see   
  11. @REM  which disks may have "Winpe" in the label. We will ignore that   
  12. @REM  disk and use the first disk without the Winpe label that we find.   
  13. @REM  *****************************************************************  
  14. @REM  create diskpart script for list disk  
  15. @ECHO.>x:\listdisk.txt  
  16. @ECHO list disk>>x:\listdisk.txt  
  17. @ECHO exit>>x:\listdisk.txt  
  18. @ECHO x:\listdisk.txt  
  19. @ECHO call diskpart /s x:\listdisk.txt  
  20. CALL diskpart /s x:\listdisk.txt>x:\Disks.txt  
  21. @ECHO.  
  22. @REM Set Disk equal to blank to start  
  23. SET disk=  
  24. @ECHO.  
  25. @REM   
  26. @REM  This line will write a diskpart script to select the disk and detail it's contents.  
  27. @REM  We use this output to find a disk that does NOT have Winpe as the volume label.  
  28. @REM  That disk will have the OS installed to it. This way you can exclude USB from diskpart.  
  29. @REM   
  30. @REM  This works around the issue where the USB key is sometimes enumerated as disk 0 and the   
  31. @REM  SSD is disk 1.   
  32. @REM  依次取磁盘0,1,2,。。。,1.如果盘符不是WINPE设置disk的值;2.如果不是WINPE又没有磁盘,设置disk=0,后面又要讨论disk 0是否为U盘,为U盘error   
  33. FOR /f "skip=8 tokens=2" %%A IN (x:\Disks.txt) DO (  
  34. @ECHO sel disk %%A>x:\Par.txt  
  35. @ECHO det disk>>x:\Par.txt  
  36. @ECHO exit>>x:\Par.txt  
  37. IF NOT "%%A"=="DiskPart..." CALL :LISTPAR %%A  
  38. )  
  39. IF "%Disk%"=="" ECHO "No disk found without a volume label of WINPE" && SET disk=0  
  40. @rem IF "%Disk%"=="" ECHO "No disk found without a volume label of WINPE" && GOTO :ERROR  
  41. @ECHO Using Disk "%Disk%"  
  42. @ECHO.  
  43.   
  44. @rem if disk  is removable, case 1 no disk,case 2 the removable device name is not winPE  
  45. @ECHO sel disk %Disk% >x:\Par_1.txt  
  46. @ECHO det disk>>x:\Par_1.txt  
  47. @ECHO exit>>x:\Par_1.txt  
  48. CALL DISKPART /S X:\Par_1.txt>X:\ParOutput_1.txt  
  49. FOR /f "skip=26 tokens=6" %%A IN (x:\ParOutput_1.txt) DO (  
  50. IF /i  "%%A"=="removable"  ECHO Disk "%Disk%" is removable device GOTO :ERROR && GOTO :ERROR  
  51. )  
  52.   
  53.   
  54.   
  55.   
  56. @ECHO.  
  57. @ECHO.  
  58. @REM  *****************************************************************  
  59. @REM    Detect if System is booted into UEFI mode or Bios mode   
  60. @REM  *****************************************************************  
  61. FOR /f "tokens=2* delims= " %%A IN ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B  
  62. @ECHO.  
  63. IF %Firmware%==0x1 GOTO :BIOSMODE  
  64. IF %Firmware%==0x2 GOTO :UEFIMODE  
  65. GOTO :END  
  66.   
  67.   
  68. :UEFIMODE  
  69. @ECHO.  
  70. @REM ************************  
  71. @REM UEFI SECTION  
  72. @REM ************************  
  73. @ECHO The PC is booted in UEFI mode  
  74. @ECHO.>x:\winpart.txt  
  75. @ECHO select disk "%Disk%">>x:\winpart.txt  
  76. @ECHO clean>>x:\winpart.txt  
  77. @ECHO convert gpt>>x:\winpart.txt  
  78. @ECHO create partition primary size=300>>x:\winpart.txt  
  79. @ECHO format quick fs=ntfs label="Windows RE tools">>x:\winpart.txt  
  80. @ECHO assign letter="T">>x:\winpart.txt  
  81. @ECHO set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\winpart.txt  
  82. @ECHO gpt attributes=0x8000000000000001>>x:\winpart.txt  
  83. @ECHO create partition efi size=100>>x:\winpart.txt  
  84. @ECHO format quick fs=fat32 label="System">>x:\winpart.txt  
  85. @ECHO assign letter="S">>x:\winpart.txt  
  86. rem @ECHO create partition msr size=128>>x:\winpart.txt  
  87. @ECHO create partition primary>>x:\winpart.txt  
  88. rem @ECHO shrink minimum=15000>>x:\winpart.txt  
  89. @ECHO format quick fs=ntfs label="Windows">>x:\winpart.txt  
  90. @ECHO assign letter="C">>x:\winpart.txt  
  91.   
  92. rem @ECHO create partition primary>>x:\winpart.txt  
  93. rem @ECHO format quick fs=ntfs label="Recovery image">>x:\winpart.txt  
  94. rem @ECHO assign letter="R">>x:\winpart.txt  
  95. rem @ECHO set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\winpart.txt  
  96. rem @ECHO gpt attributes=0x8000000000000001>>x:\winpart.txt  
  97. @ECHO list partition>>x:\winpart.txt  
  98. @ECHO list volume>>x:\winpart.txt  
  99. @ECHO exit>>x:\winpart.txt  
  100. @ECHO.  
  101. @REM *****************************************************************  
  102. @REM  Map drive letter for Install.wim  
  103. @REM *****************************************************************  
  104. @ECHO.>x:\ListVol.txt  
  105. @ECHO List volume>>x:\ListVol.txt  
  106. @ECHO exit>>x:\ListVol.txt  
  107. @ECHO call diskpart /s x:\ListVol.txt  
  108. CALL DISKPART /s x:\ListVol.txt>x:\Output.txt  
  109. @ECHO.  
  110. @ECHO.  
  111. @REM Go through each drive letter, looking for the \Scripts\Main.cmd file  
  112. FOR /f "skip=8 tokens=3" %%A IN (x:\Output.txt) DO (  
  113. IF EXIST %%A:\Scripts\Main.cmd SET InstallPath=%%A&& ECHO "Found device with images folder and Main.cmd file"  
  114. )  
  115.   
  116. @ECHO call diskpart /s x:\winpart.txt  
  117. DISKPART /s x:\winpart.txt  
  118.   
  119. rem == Apply the image to the Windows partition ==  
  120. dism /Apply-Image /ImageFile:"%InstallPath%:\Scripts\install_win8_1_x64_UEFI_CN.wim" /Index:1 /ApplyDir:C:\  
  121. rem == Copy boot files to the System partition ==  
  122. C:\Windows\System32\bcdboot C:\Windows  
  123.   
  124.   
  125. rem @ECHO copy %InstallPath%:\Scripts\ApplyImage-UEFI.bat %cd%  
  126. rem copy %InstallPath%:\Scripts\ApplyImage-UEFI.bat %cd%  
  127.   
  128. rem @ECHO ApplyImage-UEFI.bat %InstallPath%:\Scripts\install.wim  
  129. rem ApplyImage-UEFI.bat %InstallPath%:\Scripts\install.wim  
  130.   
  131.   
  132.   
  133. GOTO :WINPARTSECTION  
  134.   
  135.   
  136. :BIOSMODE  
  137. @REM ************************  
  138. @REM BIOS SECTION  
  139. @REM ************************  
  140. @ECHO The PC is booted in BIOS mode  
  141. @ECHO The PC is booted in BIOS mode>x:\Bios.txt  
  142. @ECHO.>x:\winpart.txt  
  143. @ECHO select disk "%Disk%">>x:\winpart.txt  
  144. @ECHO clean>>x:\winpart.txt  
  145. @ECHO create partition primary size=100>>x:\winpart.txt  
  146. @ECHO active>>x:\winpart.txt  
  147. @ECHO format quick fs=fat32 label="System">>x:\winpart.txt  
  148. @ECHO assign letter="S">>x:\winpart.txt  
  149. @ECHO create partition primary>>x:\winpart.txt  
  150. @ECHO format quick fs=ntfs label="Windows">>x:\winpart.txt  
  151. @ECHO assign letter="C">>x:\winpart.txt  
  152. rem @ECHO shrink desired=15000>>x:\winpart.txt  
  153. rem @ECHO create partition primary>>x:\winpart.txt  
  154. rem @ECHO format quick fs=ntfs label="Recovery image">>x:\winpart.txt  
  155. rem @ECHO assign letter="R">>x:\winpart.txt  
  156. rem @ECHO set id=27>>x:\winpart.txt  
  157. @ECHO list partition>>x:\winpart.txt  
  158. @ECHO list volume>>x:\winpart.txt  
  159. @ECHO exit>>x:\winpart.txt  
  160. @ECHO.  
  161. @REM *****************************************************************  
  162. @REM  Map drive letter for Install.wim  
  163. @REM *****************************************************************  
  164. @ECHO.>x:\ListVol.txt  
  165. @ECHO List volume>>x:\ListVol.txt  
  166. @ECHO exit>>x:\ListVol.txt  
  167. @ECHO call diskpart /s x:\ListVol.txt  
  168. CALL DISKPART /s x:\ListVol.txt>x:\Output.txt  
  169. @ECHO.  
  170. @ECHO.  
  171. @REM Go through each drive letter, looking for the \Scripts\Main.cmd file  
  172. FOR /f "skip=8 tokens=3" %%A IN (x:\Output.txt) DO (  
  173. IF EXIST %%A:\Scripts\Main.cmd SET InstallPath=%%A&& ECHO "Found device with images folder and Main.cmd file"  
  174. )  
  175.   
  176. @ECHO call diskpart /s x:\winpart.txt  
  177. DISKPART /s x:\winpart.txt  
  178.   
  179. rem == Apply the image to the Windows partition ==  
  180. dism /Apply-Image /ImageFile:"%InstallPath%:\Scripts\install_win7_x64_legacy_CN.wim" /Index:1 /ApplyDir:C:\  
  181. rem == Copy boot files to the System partition ==  
  182. C:\Windows\System32\bcdboot C:\Windows  
  183.   
  184. rem @ECHO copy %InstallPath%:\Scripts\ApplyImage-BIOS.bat %cd%  
  185. rem copy %InstallPath%:\Scripts\ApplyImage-BIOS.bat %cd%  
  186.   
  187. rem @ECHO ApplyImage-BIOS.bat %InstallPath%:\Scripts\install.wim  
  188. rem ApplyImage-BIOS.bat %InstallPath%:\Scripts\install.wim  
  189.   
  190. GOTO :WINPARTSECTION  
  191.   
  192.   
  193. :WINPARTSECTION  
  194.   
  195.   
  196.   
  197.   
  198.   
  199.   
  200. @ECHO *****************************************************************  
  201. @ECHO  Image deployment COMPLETE. Type EXIT from Command  
  202. @ECHO *****************************************************************  
  203. @ECHO.  
  204. GOTO :REBOOT  
  205.   
  206.   
  207. :LISTPAR  
  208. @REM This section is to bring a disk number and use it to List Partitions  
  209. @ECHO.  
  210. SET TempDisk=%1  
  211. DISKPART /s x:\Par.txt>x:\ParOutput.txt  
  212. FOR /f "skip=26 tokens=4" %%A IN (x:\ParOutput.txt) DO (  
  213. IF /i NOT "%%A"=="Winpe" SET Disk=%TempDisk%  
  214. )  
  215. GOTO :EOF  
  216.   
  217. :REBOOT  
  218. @REM   
  219. @REM  Get finish time so we can evaluate total WinPE phase time.  
  220. @REM  
  221. CALL |time>x:\StopTime.txt  
  222. @ECHO.  
  223. @ECHO Deployment complete, system restart.  
  224. pause  
  225. WPEUTIL REBOOT  
  226. @ECHO.  
  227.   
  228. :ERROR  
  229. @ECHO.  
  230. @ECHO An error has been detected.  
  231. COLOR 4F  
  232. @ECHO.   
  233. GOTO :END  
  234.   
  235. :END  
  236. @REM   
  237. @REM  Get finish time so we can evaluate total WinPE phase time.  
  238. @REM  
  239. CALL |time>x:\StopTime.txt  
  240. @ECHO.  
  241. FOR /f "tokens=5" %%A IN (x:\starttime.txt) DO ECHO Script Start Time is %%A  
  242. FOR /f "tokens=5" %%A IN (x:\stoptime.txt) DO ECHO  Script Stop Time is %%A  
  243. @ECHO.  


  244. main.cmd结束


  245. startnet.cmd脚本内容如下

  246. @ECHO off  
  247. @REM   
  248. @REM Initialize WinPE  
  249. @ECHO wpeinit  
  250. WPEINIT  
  251. @ECHO.  
  252. @ECHO *****************************************************************  
  253. @ECHO call wpeutil UpdateBootInfo  
  254. WPEUTIL UpdateBootInfo  
  255. @ECHO.  
  256. SET WinPEREG="HKLM\System\CurrentControlSet\Control"  
  257. SET WinPEKey=PEBootRamdiskSourceDrive  
  258. SET WinPESource=  
  259. @ECHO.  
  260. @REM Get volume letter of USB Key  
  261. @ECHO for /f "skip=2 tokens=3" %%A in ('call Reg query %WinPEREG% /v %WinPEKEY%') do set WinPESource=%%A  
  262. FOR /f "skip=2 tokens=3" %%A IN ('call Reg query %WinPEREG% /v %WinPEKEY%') DO SET WinPESource=%%A  
  263. @ECHO WinPESource is drive letter "%WinPESource%"  
  264. @ECHO.  
  265. @ECHO.  
  266. IF "%WinPESource%"=="" ECHO Drive letter NOT found.&& CALL :FINDDRIVE  
  267. @ECHO.  
  268. @ECHO.  
  269. ECHO WinPESource is "%WinPESource%"  
  270. @ECHO.  
  271. @ECHO *****************************************************************  
  272. @ECHO  Call and run main.cmd on the USB Key  
  273. @ECHO *****************************************************************  
  274. @ECHO call %WinPESource%Scripts\main.cmd  
  275. CALL %WinPESource%Scripts\main.cmd  
  276. @ECHO.  
  277. GOTO :END  
  278.   
  279. :ERROR  
  280. @ECHO.  
  281. @ECHO An error has been detected.  
  282. COLOR 4F  
  283. @ECHO.   
  284. GOTO :END  
  285.   
  286. :FINDDRIVE  
  287. @ECHO.  
  288. @ECHO Trying to find drive letter using diskpart  
  289. @ECHO.  
  290. @ECHO Lis Vol>x:\FindVol.txt  
  291. @ECHO.  
  292. @ECHO Running Diskpart to get Volume letters  
  293. @ECHO.  
  294. DISKPART /s x:\FindVol.txt>x:\VolumeList.txt  
  295. @ECHO.  
  296. @ECHO Parsing list to find WinPE  
  297. @ECHO.  
  298. FOR /f "skip=8 tokens=3-4" %%A IN (x:\VolumeList.txt) DO (  
  299. @ECHO Checking drive letter %%A has volume label of %%B  
  300. IF /i "%%B"=="WINPE" SET WinPESource=%%A  
  301. )  
  302. SET WinPESource=%WinPESource%:\  
  303. GOTO :EOF  
  304.   
  305. :END
复制代码
回复

使用道具 举报

6#
发表于 2017-10-5 22:10:22 | 只看该作者
自己搞的PE命令行自动部署,不知道合不合你胃口
链接:http://pan.baidu.com/s/1miQhF7M 密码:vmcb
回复

使用道具 举报

7#
发表于 2017-10-8 17:01:19 来自手机 | 只看该作者
受教了,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-11-28 04:39

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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