Advertisement
Guest User

WINPE-Holgi-Script

a guest
Oct 30th, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 KB | None | 0 0
  1. @ECHO OFF
  2. COLOR 0a
  3.  
  4. ::script tool to create, mount, commit, build ISOs for WinPE
  5.  
  6. SET default_img_dir=C:\WinPE_amd64
  7. :: change this to your directory of choice for convience
  8.  
  9. SET adk_dir="C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools"
  10. SET adk_env="C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\DandISetEnv.bat"
  11. :: where ADK is installed
  12. :: download the latest ADK below
  13. :: https://docs.microsoft.com/en-us/windows-hardware/get-started/adk-install
  14.  
  15. CD %adk_dir%
  16. CALL %adk_env%
  17. :: necessary for running copype & MakeWinPEMedia command within script
  18.  
  19. REM ###############################################################################
  20. :: set initial directory to be used
  21. :SetDir
  22. CLS
  23. SET img_dir=%default_img_dir%
  24. SET choice=
  25. SET /P choice=Zielverzeichnis vorgeben [%img_dir%]:
  26. IF NOT '%choice%'=='' SET img_dir=%choice%
  27. ECHO.
  28. ECHO using "%img_dir%" as image directory
  29. SET choice=
  30. SET /P choice=continue? [y]:
  31. IF /I '%choice%'=='Y' GOTO LOOP
  32. GOTO SetDir
  33.  
  34. REM ###############################################################################
  35. :: main menu
  36. :LOOP
  37. CLS
  38. ECHO #######################################
  39. ECHO # A. Mount Image #
  40. ECHO # B. Commit and Unmount Image #
  41. ECHO # C. Discard and Unmount Image #
  42. ECHO # D. Build ISO #
  43. ECHO # E. Create PE Image #
  44. ECHO # F. Download DriveSnapshot #
  45. ECHO # G. Copy DriveSnapshot to PE #
  46. ECHO # H. Modify Startnet.cmd #
  47. ECHO # I. Cleanup WIM #
  48. ECHO # K. Delete Folders #
  49. ECHO # L. Remove "Press any Key to boot" #
  50. ECHO # M. Implement German Language #
  51. ECHO # Q. Quit #
  52. ECHO #######################################
  53. ECHO.
  54.  
  55. SET choice=
  56. SET /P choice=select option:
  57. CLS
  58.  
  59. :: /I makes the IF comparison case-insensitive
  60. IF /I '%choice%'=='A' GOTO MOUNT
  61. IF /I '%choice%'=='B' GOTO COMMIT
  62. IF /I '%choice%'=='C' GOTO DISCARD
  63. IF /I '%choice%'=='D' GOTO ISO
  64. IF /I '%choice%'=='E' GOTO CreatePE
  65. IF /I '%choice%'=='F' GOTO Download
  66. IF /I '%choice%'=='G' GOTO CopySnapshot
  67. IF /I '%choice%'=='H' GOTO Startnet
  68. IF /I '%choice%'=='I' GOTO CleanUP
  69. IF /I '%choice%'=='K' GOTO Delete
  70. IF /I '%choice%'=='L' GOTO AnyKey
  71. IF /I '%choice%'=='M' GOTO German
  72. IF /I '%choice%'=='Q' EXIT
  73.  
  74. ECHO invalid input!
  75. PAUSE
  76. GOTO LOOP
  77.  
  78. REM ###############################################################################
  79. :: mount an WinPE enviornment
  80. :: mounts within image directory within subfolder "mount"
  81. :MOUNT
  82. ECHO loading image and mounting
  83. SET img_file=%img_dir%\media\sources\boot.wim
  84. SET mount_dir=%img_dir%\mount
  85. SET index=1
  86. CALL Dism /Mount-Image /ImageFile:%img_file% /index:%index% /MountDir:%mount_dir%
  87. PAUSE
  88. GOTO LOOP
  89.  
  90. REM ###############################################################################
  91. :: commit changes made to a mounted image and then unmount
  92. :COMMIT
  93. ECHO committing and unmounting...
  94. CALL Dism /Unmount-Image /MountDir:%mount_dir% /commit
  95. PAUSE
  96. GOTO LOOP
  97.  
  98. REM ###############################################################################
  99. :: discard changes made to a mounted image and then unmount
  100. :DISCARD
  101. ECHO discarding and unmounting...
  102. CALL Dism /Unmount-Image /MountDir:%mount_dir% /discard
  103. PAUSE
  104. GOTO LOOP
  105.  
  106. REM ###############################################################################
  107. :ISO
  108. :: create a bootable ISO of your WinPE enviornment
  109. :: https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-create-usb-bootable-drive?view=windows-11#create-a-winpe-iso-dvd-or-cd
  110. ECHO building ISO...
  111. SET iso_file=WinPE_amd64_Snapshot.iso
  112. CALL MakeWinPEMedia /ISO %img_dir% %img_dir%\%iso_file%
  113. PAUSE
  114. GOTO LOOP
  115.  
  116. REM ###############################################################################
  117. :CreatePE
  118. SET ark=amd64
  119. :: define arktecture
  120. :: Specify either x86, amd64, or arm
  121.  
  122. ECHO creating WinPE image at "%img_dir%"
  123. CALL copype %ark% %img_dir%
  124. :: img_dir should not already exist
  125.  
  126. PAUSE
  127. GOTO LOOP
  128.  
  129. REM ###############################################################################
  130. :Download
  131.  
  132. SET "FILENAME=%~dp0\Snapshot64.exe"
  133. bitsadmin.exe /transfer "Snapshot64.exe" /download /priority foreground "http://www.drivesnapshot.de/download/snapshot64.exe" "%FILENAME%"
  134. cls
  135. Echo Download completed!!
  136. PAUSE
  137. GOTO LOOP
  138.  
  139. REM ###############################################################################
  140. :CopySnapshot
  141. SET mount_dir=%img_dir%\mount
  142. SET FILENAME="%~dp0\Snapshot64.exe"
  143. if not exist %mount_dir%\Tools\Snapshot md %mount_dir%\Tools\Snapshot
  144. copy /y %Filename% %mount_dir%\Tools\Snapshot\
  145. Echo Snapshot64.exe copied to mount Directory
  146. PAUSE
  147. GOTO LOOP
  148.  
  149. REM ###############################################################################
  150. :Startnet
  151. SET mount_dir=%img_dir%\mount
  152.  
  153. @echo off
  154. ver
  155. set start=%mount_dir%\Windows\System32\startnet.cmd
  156. >"%start%" echo wpeinit
  157. >>"%start%" echo @echo off
  158. >>"%start%" echo wpeutil InitializeNetwork
  159. >>"%start%" echo wpeutil SetKeyboardLayout 0407:00000407
  160. >>"%start%" echo start "" "X:\Tools\Snapshot\snapshot64.exe"
  161. Echo Startnet Bearbeitung fertig!
  162. PAUSE
  163. GOTO LOOP
  164.  
  165. REM ###############################################################################
  166. :Cleanup
  167. SET mount_dir=%img_dir%\mount
  168. dism /cleanup-wim
  169. Echo WIM Cleanup erledigt!
  170. PAUSE
  171. GOTO LOOP
  172.  
  173. REM ###############################################################################
  174. :Delete
  175. RD %img_dir% /s /q
  176. Echo WINPE Folder removed!
  177. PAUSE
  178. GOTO LOOP
  179.  
  180. REM ###############################################################################
  181. :AnyKey
  182.  
  183. copy /y "%ProgramFiles(x86)%\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\efisys_noprompt.bin" "%img_dir%\fwfiles/efisys.bin"
  184. Echo AnyKey removed!
  185. PAUSE
  186. GOTO LOOP
  187.  
  188. REM ###############################################################################
  189. :German
  190. SET mount_dir=%img_dir%\mount
  191. dism /image:%mount_dir% /add-package /packagepath:"%ProgramFiles(x86)%\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\de-de\lp.cab"
  192. cls
  193. dism /image:%mount_dir% /set-allintl:de-DE
  194. cls
  195. Echo German Language installed!
  196. PAUSE
  197. GOTO LOOP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement