commit 13ee0ecb2e5abbbaae09f9c3be667749ae0052bd Author: Bram Prieshof Date: Thu Mar 16 23:54:00 2023 +0100 Inital Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b479f33 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +PEBuilderConfig.cmd +*.iso +*.wim \ No newline at end of file diff --git a/Build_WinPE-SMBInstaller.cmd b/Build_WinPE-SMBInstaller.cmd new file mode 100644 index 0000000..6a4ee08 --- /dev/null +++ b/Build_WinPE-SMBInstaller.cmd @@ -0,0 +1,62 @@ +@echo off +REM ElevationCheck +NET SESSION >nul 2>&1 +IF %ERRORLEVEL% NEQ 0 ( + ECHO Please run this script as administrator + PAUSE + EXIT +) + +REM Buildconf +set BuildEdition=SMBInstaller + +REM Setup Enviroment +REM Check if home has PEBuilderConfig if not check the current folder when no config was found quit +IF EXIST "%UserProfile%\PEBuilderConfig.cmd" ( + call %UserProfile%\PEBuilderConfig.cmd +) ELSE ( + IF EXIST "%~dp0\PEBuilderConfig.cmd" ( + call "%~dp0\PEBuilderConfig.cmd" + ) ELSE ( + echo Config not found, exiting + pause + exit + ) +) +call "%ADKPath%\Deployment Tools\DandISetEnv.bat" +set PEPath=C:\WinPE_%BuildEdition% + +REM Prepeare PE +call copype amd64 %PEPath% + +REM Mount WIM image +Dism /Mount-Image /ImageFile:"%PEPath%\media\sources\boot.wim" /index:1 /MountDir:"%PEPath%\mount" + +REM Add PE-SMB Installer files +xcopy /E /I /H /Y "%~dp0Overlay" "%PEPath%\mount" + +REM add WMI module +Dism /Add-Package /Image:"%PEPath%\mount" /PackagePath:"%ADKPath%\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab" +Dism /Add-Package /Image:"%PEPath%\mount" /PackagePath:"%ADKPath%\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab" + +REM add WinPE-SecureStartup module +Dism /Add-Package /Image:"%PEPath%\mount" /PackagePath:"%ADKPath%\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-SecureStartup.cab" +Dism /Add-Package /Image:"%PEPath%\mount" /PackagePath:"%ADKPath%\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-SecureStartup_en-us.cab" + +REM Unmount WIM image +Dism /Unmount-Image /MountDir:"%PEPath%\mount" /commit +Dism /Cleanup-Mountpoints + +REM Create ISO (Disabled by default) +REM call MakeWinPEMedia /ISO %PEPath% "%~dp0Winpe%ADKVersion%_%BuildEdition%.iso" + +REM Copy WIM File to output folder +echo Saving %~dp0Winpe%ADKVersion%_%BuildEdition%.wim +copy %PEPath%\media\sources\boot.wim %~dp0Winpe%ADKVersion%_%BuildEdition%.wim + +REM remove BuildDir +rmdir /q /s %PEPath% + +REM end +echo Done +pause \ No newline at end of file diff --git a/IpxeConfig/MountConfigGeneric.cmd b/IpxeConfig/MountConfigGeneric.cmd new file mode 100644 index 0000000..5dd24bc --- /dev/null +++ b/IpxeConfig/MountConfigGeneric.cmd @@ -0,0 +1,9 @@ +REM SMB config mount config for WinPEInstaller +set SmbServer=192.168.2.94 +set SmbUser=.\installer +set SmbPassword=installer +set SmbFolder=WindowsInstallers + +REM Used to add pefix to options in version menu,Keep tailing space +rem set "VersionPrefix=Windows 10 " +rem set "VersionPrefix=Windows 11 " \ No newline at end of file diff --git a/IpxeConfig/MountConfigW10.cmd b/IpxeConfig/MountConfigW10.cmd new file mode 100644 index 0000000..f6d3d2d --- /dev/null +++ b/IpxeConfig/MountConfigW10.cmd @@ -0,0 +1,9 @@ +REM SMB config mount config for WinPEInstaller +set SmbServer=192.168.2.94 +set SmbUser=.\installer +set SmbPassword=installer +set SmbFolder=Windows10 + +REM Used to add pefix to options in version menu,Keep tailing space +set "VersionPrefix=Windows 10 " +rem set "VersionPrefix=Windows 11 " \ No newline at end of file diff --git a/IpxeConfig/MountConfigW11.cmd b/IpxeConfig/MountConfigW11.cmd new file mode 100644 index 0000000..2323abf --- /dev/null +++ b/IpxeConfig/MountConfigW11.cmd @@ -0,0 +1,9 @@ +REM SMB config mount config for WinPEInstaller +set SmbServer=192.168.2.94 +set SmbUser=.\installer +set SmbPassword=installer +set SmbFolder=Windows11 + +REM Used to add pefix to options in version menu,Keep tailing space +rem set "VersionPrefix=Windows 10 " +set "VersionPrefix=Windows 11 " \ No newline at end of file diff --git a/IpxeConfig/bootExample.ipxe b/IpxeConfig/bootExample.ipxe new file mode 100644 index 0000000..c884cb8 --- /dev/null +++ b/IpxeConfig/bootExample.ipxe @@ -0,0 +1,8 @@ +#!ipxe +#Uses iPxe WimBoot https://ipxe.org/wimboot +kernel ${Boot-Root}/loader-wimboot/wimboot +initrd ${Boot-Root}/loader-wimboot/BCD BCD +initrd ${Boot-Root}/loader-wimboot/boot.sdi boot.sdi +initrd --name MountConfig.cmd ${Boot-Root}/Tools/MountConfigGeneric.cmd MountConfig.cmd +initrd --name boot.wim ${Boot-Root}/Tools/WinPENetInstaller.wim boot.wim +boot \ No newline at end of file diff --git a/Overlay/SMBInstaller/InitMenu.cmd b/Overlay/SMBInstaller/InitMenu.cmd new file mode 100644 index 0000000..4bfde63 --- /dev/null +++ b/Overlay/SMBInstaller/InitMenu.cmd @@ -0,0 +1,77 @@ +@ECHO OFF +TITLE Preparing installation +REM load config +call MountConfig.cmd + +ECHO -------------------------------- +ECHO Welcome to WinPE SMB installer +ECHO\ +ECHO by Brammp +ECHO -------------------------------- +ECHO\ + +echo Waiting for network +REM Load network +wpeinit +wpeinit network +REM Test network +:TestNetworkConnection +ping -n 1 %SmbServer% | find "TTL=" >nul +if errorlevel 1 ( + goto Retry +) else ( + goto ExecSMB +) + +:Retry +ping 192.0.2.1 -n 5 -w 2000 >nul +goto :TestNetworkConnection + +:ExecSMB +rem echo "Connection OK." + +rem Mount network share +set SmbRetry=0 +ECHO Waiting for SMB + +:SmbMount +net use I: \\%SmbServer%\%SmbFolder% /user:%SmbUser% %SmbPassword% >null 2>&1 + +IF not exist I:\ ( + + set /A SmbRetry+=1 >null + REM ECHO SMB Failed Count: %SmbRetry% + REM ECHO Retrying in 2sec + ping 127.0.0.1 -n 5 -w 2000 >nul + GOTO SmbMount +) ELSE ( + GOTO ExecMenu +) + + +:ExecMenu +rem Go to network share +i: + +setlocal EnableDelayedExpansion +rem Show menu with availible Versions +ECHO Available releases: +ECHO\ +set i=0 +for /D %%f in ("*") do ( + set /A i+=1 + echo !i!. %VersionPrefix%%%f + set "option[!i!]=%%f" +) +ECHO\ +:getChoice +set /P "choice=Enter desired option: " +if "!option[%choice%]!" equ "" echo ERROR: no such option & goto getChoice +set "SelectedRelease=!option[%choice%]!" + +echo | set /p=%SelectedRelease%>%TEMP%\SelectedRelease.var + +ECHO\ +ECHO Loading setup for %VersionPrefix%%SelectedRelease% +ping 192.0.2.1 -n 2 -w 2000 >nul +exit \ No newline at end of file diff --git a/Overlay/SMBInstaller/LoadSetup.cmd b/Overlay/SMBInstaller/LoadSetup.cmd new file mode 100644 index 0000000..dd78bf8 --- /dev/null +++ b/Overlay/SMBInstaller/LoadSetup.cmd @@ -0,0 +1,20 @@ +@ECHO OFF +TITLE Loading windows setup +REM load needed var(s) +set /p SelectedRelease=<%TEMP%\SelectedRelease.var + +set SetupFound=FALSE +REM go to setUp location +I: +cd \%SelectedRelease% + +REM Check if setup exists +IF exist setup.exe ( + set SetupFound=TRUE + REM load setUp + start /wait setup.exe +) + +echo | set /p=%SetupFound%>%TEMP%\SetupFound.var + +REM exit \ No newline at end of file diff --git a/Overlay/SMBInstaller/PowerMenu.cmd b/Overlay/SMBInstaller/PowerMenu.cmd new file mode 100644 index 0000000..2974f80 --- /dev/null +++ b/Overlay/SMBInstaller/PowerMenu.cmd @@ -0,0 +1,24 @@ +@ECHO OFF +TITLE Power menu +REM load needed var(s) +set /p SetupFound=<%TEMP%\SetupFound.var + +IF %SetupFound% == FALSE ( + echo Setup not found + pause +) + + +:PowerMenu +ECHO\ +ECHO ............................................... +ECHO PRESS 1 to poweroff, or 2 to reboot +ECHO ............................................... +ECHO\ +ECHO 1 - Poweroff +ECHO 2 - Reboot +ECHO\ +SET /P M=Type 1 or 2 then press ENTER: +IF %M%==1 wpeutil shutdown +IF %M%==2 wpeutil reboot +GOTO PowerMenu \ No newline at end of file diff --git a/Overlay/Windows/System32/Winpeshl.ini b/Overlay/Windows/System32/Winpeshl.ini new file mode 100644 index 0000000..6c2b683 --- /dev/null +++ b/Overlay/Windows/System32/Winpeshl.ini @@ -0,0 +1,4 @@ +[LaunchApps] +X:/SMBInstaller/InitMenu.cmd +X:/SMBInstaller/LoadSetup.cmd +X:/SMBInstaller/PowerMenu.cmd \ No newline at end of file diff --git a/PEBuilderConfig.cmd.example b/PEBuilderConfig.cmd.example new file mode 100644 index 0000000..bb4cc23 --- /dev/null +++ b/PEBuilderConfig.cmd.example @@ -0,0 +1,2 @@ +set ADKPath=C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit +set ADKVersion=W10 \ No newline at end of file