Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- COLOR 0a
- ::script tool to create, mount, commit, build ISOs for WinPE
- SET default_img_dir=C:\WinPE_amd64
- :: change this to your directory of choice for convience
- SET adk_dir="C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools"
- SET adk_env="C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\DandISetEnv.bat"
- :: where ADK is installed
- :: download the latest ADK below
- :: https://docs.microsoft.com/en-us/windows-hardware/get-started/adk-install
- CD %adk_dir%
- CALL %adk_env%
- :: necessary for running copype & MakeWinPEMedia command within script
- REM ###############################################################################
- :: set initial directory to be used
- :SetDir
- CLS
- SET img_dir=%default_img_dir%
- SET choice=
- SET /P choice=Zielverzeichnis vorgeben [%img_dir%]:
- IF NOT '%choice%'=='' SET img_dir=%choice%
- ECHO.
- ECHO using "%img_dir%" as image directory
- SET choice=
- SET /P choice=continue? [y]:
- IF /I '%choice%'=='Y' GOTO LOOP
- GOTO SetDir
- REM ###############################################################################
- :: main menu
- :LOOP
- CLS
- ECHO #######################################
- ECHO # A. Mount Image #
- ECHO # B. Commit and Unmount Image #
- ECHO # C. Discard and Unmount Image #
- ECHO # D. Build ISO #
- ECHO # E. Create PE Image #
- ECHO # F. Download DriveSnapshot #
- ECHO # G. Copy DriveSnapshot to PE #
- ECHO # H. Modify Startnet.cmd #
- ECHO # I. Cleanup WIM #
- ECHO # K. Delete Folders #
- ECHO # L. Remove "Press any Key to boot" #
- ECHO # M. Implement German Language #
- ECHO # Q. Quit #
- ECHO #######################################
- ECHO.
- SET choice=
- SET /P choice=select option:
- CLS
- :: /I makes the IF comparison case-insensitive
- IF /I '%choice%'=='A' GOTO MOUNT
- IF /I '%choice%'=='B' GOTO COMMIT
- IF /I '%choice%'=='C' GOTO DISCARD
- IF /I '%choice%'=='D' GOTO ISO
- IF /I '%choice%'=='E' GOTO CreatePE
- IF /I '%choice%'=='F' GOTO Download
- IF /I '%choice%'=='G' GOTO CopySnapshot
- IF /I '%choice%'=='H' GOTO Startnet
- IF /I '%choice%'=='I' GOTO CleanUP
- IF /I '%choice%'=='K' GOTO Delete
- IF /I '%choice%'=='L' GOTO AnyKey
- IF /I '%choice%'=='M' GOTO German
- IF /I '%choice%'=='Q' EXIT
- ECHO invalid input!
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :: mount an WinPE enviornment
- :: mounts within image directory within subfolder "mount"
- :MOUNT
- ECHO loading image and mounting
- SET img_file=%img_dir%\media\sources\boot.wim
- SET mount_dir=%img_dir%\mount
- SET index=1
- CALL Dism /Mount-Image /ImageFile:%img_file% /index:%index% /MountDir:%mount_dir%
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :: commit changes made to a mounted image and then unmount
- :COMMIT
- ECHO committing and unmounting...
- CALL Dism /Unmount-Image /MountDir:%mount_dir% /commit
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :: discard changes made to a mounted image and then unmount
- :DISCARD
- ECHO discarding and unmounting...
- CALL Dism /Unmount-Image /MountDir:%mount_dir% /discard
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :ISO
- :: create a bootable ISO of your WinPE enviornment
- :: 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
- ECHO building ISO...
- SET iso_file=WinPE_amd64_Snapshot.iso
- CALL MakeWinPEMedia /ISO %img_dir% %img_dir%\%iso_file%
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :CreatePE
- SET ark=amd64
- :: define arktecture
- :: Specify either x86, amd64, or arm
- ECHO creating WinPE image at "%img_dir%"
- CALL copype %ark% %img_dir%
- :: img_dir should not already exist
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :Download
- SET "FILENAME=%~dp0\Snapshot64.exe"
- bitsadmin.exe /transfer "Snapshot64.exe" /download /priority foreground "http://www.drivesnapshot.de/download/snapshot64.exe" "%FILENAME%"
- cls
- Echo Download completed!!
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :CopySnapshot
- SET mount_dir=%img_dir%\mount
- SET FILENAME="%~dp0\Snapshot64.exe"
- if not exist %mount_dir%\Tools\Snapshot md %mount_dir%\Tools\Snapshot
- copy /y %Filename% %mount_dir%\Tools\Snapshot\
- Echo Snapshot64.exe copied to mount Directory
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :Startnet
- SET mount_dir=%img_dir%\mount
- @echo off
- ver
- set start=%mount_dir%\Windows\System32\startnet.cmd
- >"%start%" echo wpeinit
- >>"%start%" echo @echo off
- >>"%start%" echo wpeutil InitializeNetwork
- >>"%start%" echo wpeutil SetKeyboardLayout 0407:00000407
- >>"%start%" echo start "" "X:\Tools\Snapshot\snapshot64.exe"
- Echo Startnet Bearbeitung fertig!
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :Cleanup
- SET mount_dir=%img_dir%\mount
- dism /cleanup-wim
- Echo WIM Cleanup erledigt!
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :Delete
- RD %img_dir% /s /q
- Echo WINPE Folder removed!
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :AnyKey
- copy /y "%ProgramFiles(x86)%\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\efisys_noprompt.bin" "%img_dir%\fwfiles/efisys.bin"
- Echo AnyKey removed!
- PAUSE
- GOTO LOOP
- REM ###############################################################################
- :German
- SET mount_dir=%img_dir%\mount
- 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"
- cls
- dism /image:%mount_dir% /set-allintl:de-DE
- cls
- Echo German Language installed!
- PAUSE
- GOTO LOOP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement