Skip to content

Commit

Permalink
[PE Helper] Add custom restart countdown dialog
Browse files Browse the repository at this point in the history
Source code for dialog will be available in a separate repo
  • Loading branch information
CodingWonders committed Oct 16, 2024
1 parent 5775f4e commit 2ee5d92
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
6 changes: 6 additions & 0 deletions DISMTools.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,12 @@
<Content Include="Helpers\extps1\PE_Helper\tools\DIM\i386\DT-DIM.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Helpers\extps1\PE_Helper\tools\RestartDialog\amd64\DTPE-RestartDialog.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Helpers\extps1\PE_Helper\tools\RestartDialog\i386\DTPE-RestartDialog.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Installer\dt.iss" />
<Content Include="Installer\ISCC.exe" />
<Content Include="Installer\ISCmplr.dll" />
Expand Down
34 changes: 29 additions & 5 deletions Helpers/extps1/PE_Helper/PE_Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ function Start-PEGeneration
Copy-Item -Path "$((Get-Location).Path)\files\README1ST.TXT" -Destination "$((Get-Location).Path)\ISOTEMP\media\README.TXT" -Verbose -Force -Recurse -Container -ErrorAction SilentlyContinue
New-Item -Path "$((Get-Location).Path)\ISOTEMP\media\Tools\DIM" -ItemType Directory | Out-Null
Copy-Item -Path "$((Get-Location).Path)\tools\DIM\*" -Destination "$((Get-Location).Path)\ISOTEMP\media\Tools\DIM" -Verbose -Force -Recurse -Container -ErrorAction SilentlyContinue
New-Item -Path "$((Get-Location).Path)\ISOTEMP\media\Tools\RestartDialog" -ItemType Directory | Out-Null
Copy-Item -Path "$((Get-Location).Path)\tools\RestartDialog\*" -Destination "$((Get-Location).Path)\ISOTEMP\media\Tools\RestartDialog" -Verbose -Force -Recurse -Container -ErrorAction SilentlyContinue
if (($unattendFile -ne "") -and (Test-Path "$unattendFile" -PathType Leaf))
{
Write-Host "Unattended answer file has been detected. Copying to ISO file..."
Expand Down Expand Up @@ -807,11 +809,33 @@ function Start-OSApplication
}
New-BootFiles -drLetter $driveLetter -bootPart "auto" -diskId $drive -cleanDrive $($partition -eq 0)
Start-Sleep -Milliseconds 250
# Show message before rebooting system
Write-Host "The first stage of Setup has completed, and your system will reboot automatically."
Write-Host "If there are any bootable devices, remove those before proceeding, as your system may boot to this environment again."
Write-Host "When your computer restarts, Setup will continue."
Show-Timeout -Seconds 10
try
{
# Get CPU architecture and launch Driver Installation Module
$supportedArchitectures = [List[string]]::new()
$supportedArchitectures.Add("i386")
$supportedArchitectures.Add("amd64")
$systemArchitecture = Get-SystemArchitecture

if ($supportedArchitectures.Contains($systemArchitecture))
{
if (Test-Path -Path "$([IO.Path]::GetPathRoot([Environment]::GetFolderPath([Environment+SpecialFolder]::Windows)))Tools\RestartDialog\$systemArchitecture\DTPE-RestartDialog.exe")
{
Start-Process -FilePath "$([IO.Path]::GetPathRoot([Environment]::GetFolderPath([Environment+SpecialFolder]::Windows)))Tools\RestartDialog\$systemArchitecture\DTPE-RestartDialog.exe" -Wait
}
}

Start-Sleep -Milliseconds 250
Write-Host "Restarting your system..."
}
catch
{
# Show message before rebooting system
Write-Host "The first stage of Setup has completed, and your system will reboot automatically."
Write-Host "If there are any bootable devices, remove those before proceeding, as your system may boot to this environment again."
Write-Host "When your computer restarts, Setup will continue."
Show-Timeout -Seconds 10
}
wpeutil reboot
}

Expand Down
4 changes: 4 additions & 0 deletions Helpers/extps1/PE_Helper/files/startup/startnet.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ if %debug% lss 2 (
if not exist "%sysdrive%\Tools\DIM" (md "%sysdrive%\Tools\DIM")
xcopy "%%D:\Tools\DIM\*" "%sysdrive%\Tools\DIM" /cehyi > nul
)
if exist "%%D:\Tools\RestartDialog" (
if not exist "%sysdrive%\Tools\RestartDialog" (md "%sysdrive%\Tools\RestartDialog")
xcopy "%%D:\Tools\RestartDialog\*" "%sysdrive%\Tools\RestartDialog" /cehyi > nul
)
powershell .\PE_Helper.ps1 StartApply
)
)
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 2ee5d92

Please sign in to comment.