From 49dac34d8769041c63a0d296d15a3b738e2c8a45 Mon Sep 17 00:00:00 2001 From: Snshadow Date: Wed, 15 Jan 2025 11:28:39 +0900 Subject: [PATCH 01/10] several-fixes - Edit README.md part for `Set-ExecutionPolicy` to use `-Scope Process` to prevent changing the entire computer's policy. - Fix tiny11maker.ps1 and tiny11Coremaker.ps1 to find oscdimg.exe from registry instead of using fixed path. - Add Run.bat helper batch file(referenced from Win11Debloat) to help running tiny11maker with double clicking. --- README.md | 2 +- Run.bat | 5 +++++ tiny11Coremaker.ps1 | 13 ++++++++----- tiny11maker.ps1 | 10 +++++++--- 4 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 Run.bat diff --git a/README.md b/README.md index f39750b..40c33a2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ You can now use it on ANY Windows 11 release (not just a specific build), as wel This is made possible thanks to the much-improved scripting capabilities of PowerShell, compared to the older Batch release.
Since it is written in PowerShell, you need to set the execution policy to `Unrestricted`, so that you could run the script. -If you haven't done this before, make sure to run `Set-ExecutionPolicy unrestricted` as administrator in PowerShell before running the script, otherwise it would just crash. +If you haven't done this before, make sure to run `Set-ExecutionPolicy -Scope Process unrestricted` as administrator in PowerShell before running the script, otherwise it would just crash. This is a script created to automate the build of a streamlined Windows 11 image, similar to tiny11. diff --git a/Run.bat b/Run.bat new file mode 100644 index 0000000..996c80a --- /dev/null +++ b/Run.bat @@ -0,0 +1,5 @@ +:: Reference from https://github.com/Raphire/Win11Debloat/blob/master/Run.bat licensed under MIT license. + +@echo off + +Powershell -ExecutionPolicy Bypass -Command "& {Start-Process Powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dp0tiny11maker.ps1""' -Verb RunAs}" diff --git a/tiny11Coremaker.ps1 b/tiny11Coremaker.ps1 index 18b9490..2ff4a04 100644 --- a/tiny11Coremaker.ps1 +++ b/tiny11Coremaker.ps1 @@ -730,16 +730,19 @@ Write-Host "Exporting ESD. This may take a while..." Remove-Item "$mainOSDrive\tiny11\sources\install.wim" > $null 2>&1 Write-Host "The tiny11 image is now completed. Proceeding with the making of the ISO..." Write-Host "Creating ISO image..." -$ADKDepTools = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" +# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach), trim the following backslash for path concatenation. +$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null).TrimEnd('\') +if ($null -ne $WinSDKPath) { + $ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" +} $localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe" -if ([System.IO.Directory]::Exists($ADKDepTools)) { +if ((Test-Path variable:ADKDepTools) -and (Test-Path "$ADKDepTools\oscdimg.exe" -PathType leaf)) { Write-Host "Will be using oscdimg.exe from system ADK." $OSCDIMG = "$ADKDepTools\oscdimg.exe" } else { - Write-Host "ADK folder not found. Will be using bundled oscdimg.exe." - - + Write-Host "oscdimg.exe from system ADK not found. Will be using bundled oscdimg.exe." + $url = "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe" if (-not (Test-Path -Path $localOSCDIMGPath)) { diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index 03dfedd..d2c3cf4 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -436,14 +436,18 @@ Write-Host "The tiny11 image is now completed. Proceeding with the making of the Write-Host "Copying unattended file for bypassing MS account on OOBE..." Copy-Item -Path "$PSScriptRoot\autounattend.xml" -Destination "$ScratchDisk\tiny11\autounattend.xml" -Force | Out-Null Write-Host "Creating ISO image..." -$ADKDepTools = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" +# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach), trim the following backslash for path concatenation. +$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null).TrimEnd('\') +if ($null -ne $WinSDKPath) { + $ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" +} $localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe" -if ([System.IO.Directory]::Exists($ADKDepTools)) { +if ((Test-Path variable:ADKDepTools) -and (Test-Path "$ADKDepTools\oscdimg.exe" -PathType leaf)) { Write-Host "Will be using oscdimg.exe from system ADK." $OSCDIMG = "$ADKDepTools\oscdimg.exe" } else { - Write-Host "ADK folder not found. Will be using bundled oscdimg.exe." + Write-Host "oscdimg.exe from system ADK not found. Will be using bundled oscdimg.exe." $url = "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe" From b0750f317ccf8c7a3a952fc57217706918713b63 Mon Sep 17 00:00:00 2001 From: Snshadow Date: Wed, 15 Jan 2025 12:12:13 +0900 Subject: [PATCH 02/10] fix: change disallowing ExecutionPolicy - Add AllSigned, Undefined for consideration which also prevent script from running --- tiny11Coremaker.ps1 | 10 ++++++---- tiny11maker.ps1 | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tiny11Coremaker.ps1 b/tiny11Coremaker.ps1 index 2ff4a04..39c9ce7 100644 --- a/tiny11Coremaker.ps1 +++ b/tiny11Coremaker.ps1 @@ -1,12 +1,14 @@ # Enable debugging Set-PSDebug -Trace 1 -# Check if PowerShell execution is restricted -if ((Get-ExecutionPolicy) -eq 'Restricted') { - Write-Host "Your current PowerShell Execution Policy is set to Restricted, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)" +# Check if PowerShell execution is Restricted or AllSigned or Undefined +$needchange = @("AllSigned", "Restricted", "Undefined") +$curpolicy = Get-ExecutionPolicy +if ($curpolicy -in $needchange) { + Write-Host "Your current PowerShell Execution Policy is set to $curpolicy, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)" $response = Read-Host if ($response -eq 'yes') { - Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false + Set-ExecutionPolicy RemoteSigned -Scope Process -Confirm:$false } else { Write-Host "The script cannot be run without changing the execution policy. Exiting..." exit diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index d2c3cf4..1f1a613 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -14,12 +14,14 @@ if (-not $ScratchDisk) { Write-Output "Scratch disk set to $ScratchDisk" -# Check if PowerShell execution is restricted -if ((Get-ExecutionPolicy) -eq 'Restricted') { - Write-Host "Your current PowerShell Execution Policy is set to Restricted, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)" +# Check if PowerShell execution is Restricted or AllSigned or Undefined +$needchange = @("AllSigned", "Restricted", "Undefined") +$curpolicy = Get-ExecutionPolicy +if ($curpolicy -in $needchange) { + Write-Host "Your current PowerShell Execution Policy is set to $curpolicy, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)" $response = Read-Host if ($response -eq 'yes') { - Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false + Set-ExecutionPolicy RemoteSigned -Scope Process -Confirm:$false } else { Write-Host "The script cannot be run without changing the execution policy. Exiting..." exit From e1273fe6cadd3593c730df59f6e23e2a11196eec Mon Sep 17 00:00:00 2001 From: Snshadow Date: Wed, 15 Jan 2025 13:18:58 +0900 Subject: [PATCH 03/10] fix: do not call method on $null object - fix the cause of crash if ADK is not installed --- tiny11Coremaker.ps1 | 6 ++++-- tiny11maker.ps1 | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tiny11Coremaker.ps1 b/tiny11Coremaker.ps1 index 39c9ce7..0d19569 100644 --- a/tiny11Coremaker.ps1 +++ b/tiny11Coremaker.ps1 @@ -732,9 +732,11 @@ Write-Host "Exporting ESD. This may take a while..." Remove-Item "$mainOSDrive\tiny11\sources\install.wim" > $null 2>&1 Write-Host "The tiny11 image is now completed. Proceeding with the making of the ISO..." Write-Host "Creating ISO image..." -# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach), trim the following backslash for path concatenation. -$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null).TrimEnd('\') +# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach). +$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) if ($null -ne $WinSDKPath) { + # Trim the following backslash for path concatenation. + $WinSDKPath = $WinSDKPath.TrimEnd('\') $ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" } $localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe" diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index 1f1a613..56761b2 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -438,9 +438,11 @@ Write-Host "The tiny11 image is now completed. Proceeding with the making of the Write-Host "Copying unattended file for bypassing MS account on OOBE..." Copy-Item -Path "$PSScriptRoot\autounattend.xml" -Destination "$ScratchDisk\tiny11\autounattend.xml" -Force | Out-Null Write-Host "Creating ISO image..." -# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach), trim the following backslash for path concatenation. -$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null).TrimEnd('\') +# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach). +$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) if ($null -ne $WinSDKPath) { + # Trim the following backslash for path concatenation. + $WinSDKPath = $WinSDKPath.TrimEnd('\') $ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" } $localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe" From f1e79e8d16f982a5e1d8878e124dd19bfd634935 Mon Sep 17 00:00:00 2001 From: Snshadow Date: Wed, 15 Jan 2025 17:26:46 +0900 Subject: [PATCH 04/10] update: powershell dism feature and provisoned appx - Get architecture using Get-WindowsImage and its property directly. - Use Get-AppxProvisionedPackage and Remove-AppxProvisionedPackage instead if dism for more consistence. - Use Export-WindowsImage with -CompressionType Maximum instead of Fast for smaller type(used to be recovery with dism.exe). --- tiny11Coremaker.ps1 | 2 +- tiny11maker.ps1 | 41 +++++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/tiny11Coremaker.ps1 b/tiny11Coremaker.ps1 index 0d19569..6ac462d 100644 --- a/tiny11Coremaker.ps1 +++ b/tiny11Coremaker.ps1 @@ -122,7 +122,7 @@ $packages = & 'dism' '/English' "/image:$($env:SystemDrive)\scratchdir" '/Get-Pr $matches[1] } } -$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.SecHealthUI_', 'Microsoft.Windows.PeopleExperienceHost_', 'Microsoft.Windows.PinningConfirmationDialog_', 'Windows.CBSPreview_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'Microsoft.549981C3F5F10_' +$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.SecHealthUI_', 'Microsoft.Windows.PeopleExperienceHost_', 'Microsoft.Windows.PinningConfirmationDialog_', 'Windows.CBSPreview_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'MSTeams_', 'Microsoft.549981C3F5F10_' $packagesToRemove = $packages | Where-Object { $packageName = $_ diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index 56761b2..44b7a86 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -100,8 +100,9 @@ try { # This block will catch the error and suppress it. } New-Item -ItemType Directory -Force -Path "$ScratchDisk\scratchdir" > $null -Mount-WindowsImage -ImagePath $ScratchDisk\tiny11\sources\install.wim -Index $index -Path $ScratchDisk\scratchdir +Mount-WindowsImage -ImagePath $wimFilePath -Index $index -Path $ScratchDisk\scratchdir +# Powershell dism module does not have direct equivalent for /Get-Intl $imageIntl = & dism /English /Get-Intl "/Image:$($ScratchDisk)\scratchdir" $languageLine = $imageIntl -split '\n' | Where-Object { $_ -match 'Default system UI language : ([a-zA-Z]{2}-[a-zA-Z]{2})' } @@ -112,41 +113,37 @@ if ($languageLine) { Write-Host "Default system UI language code not found." } -$imageInfo = & 'dism' '/English' '/Get-WimInfo' "/wimFile:$($ScratchDisk)\tiny11\sources\install.wim" "/index:$index" -$lines = $imageInfo -split '\r?\n' - -foreach ($line in $lines) { - if ($line -like '*Architecture : *') { - $architecture = $line -replace 'Architecture : ','' - # If the architecture is x64, replace it with amd64 - if ($architecture -eq 'x64') { - $architecture = 'amd64' - } - Write-Host "Architecture: $architecture" - break - } +# Defined in (Microsoft.Dism.Commands.ImageInfoObject).Architecture formatting script +# 0 -> x86, 5 -> arm(currently unused), 6 -> ia64(currently unused), 9 -> x64, 12 -> arm64 +switch ((Get-WindowsImage -ImagePath $wimFilePath -Index $index).Architecture) +{ + 0 { $architecture = "x86" } + 9 { $architecture = "amd64" } + 12 {$architecture = "arm64" } } -if (-not $architecture) { +if (Test-Path variable:architecture) { + Write-Host "Architecture: $architecture" +} else { Write-Host "Architecture information not found." } + Write-Host "Mounting complete! Performing removal of applications..." -$packages = & 'dism' '/English' "/image:$($ScratchDisk)\scratchdir" '/Get-ProvisionedAppxPackages' | +$packages = Get-ProvisionedAppxPackage -Path "$ScratchDisk\scratchdir" | ForEach-Object { - if ($_ -match 'PackageName : (.*)') { - $matches[1] - } + $_.PackageName } -$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'Microsoft.549981C3F5F10_' + +$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'MSTeams_', 'Microsoft.549981C3F5F10_' $packagesToRemove = $packages | Where-Object { $packageName = $_ $packagePrefixes -contains ($packagePrefixes | Where-Object { $packageName -like "$_*" }) } foreach ($package in $packagesToRemove) { - & 'dism' '/English' "/image:$($ScratchDisk)\scratchdir" '/Remove-ProvisionedAppxPackage' "/PackageName:$package" + Remove-AppxProvisionedPackage -Path "$ScratchDisk\scratchdir" -PackageName "$package" } @@ -391,7 +388,7 @@ Write-Host "Unmounting image..." Dismount-WindowsImage -Path $ScratchDisk\scratchdir -Save Write-Host "Exporting image..." # Compressiontype Recovery is not supported with PShell https://learn.microsoft.com/en-us/powershell/module/dism/export-windowsimage?view=windowsserver2022-ps#-compressiontype -Export-WindowsImage -SourceImagePath $ScratchDisk\tiny11\sources\install.wim -SourceIndex $index -DestinationImagePath $ScratchDisk\tiny11\sources\install2.wim -CompressionType Fast +Export-WindowsImage -SourceImagePath $ScratchDisk\tiny11\sources\install.wim -SourceIndex $index -DestinationImagePath $ScratchDisk\tiny11\sources\install2.wim -CompressionType Maximum Remove-Item -Path "$ScratchDisk\tiny11\sources\install.wim" -Force | Out-Null Rename-Item -Path "$ScratchDisk\tiny11\sources\install2.wim" -NewName "install.wim" | Out-Null Write-Host "Windows image completed. Continuing with boot.wim." From e9d131c6915379b418023ba1b8b6122072fdb4e1 Mon Sep 17 00:00:00 2001 From: Snshadow Date: Thu, 16 Jan 2025 08:36:06 +0900 Subject: [PATCH 05/10] refactor: use explict parameters - align switch block --- tiny11maker.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index 44b7a86..f3f880e 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -119,7 +119,7 @@ switch ((Get-WindowsImage -ImagePath $wimFilePath -Index $index).Architecture) { 0 { $architecture = "x86" } 9 { $architecture = "amd64" } - 12 {$architecture = "arm64" } + 12 { $architecture = "arm64" } } if (Test-Path variable:architecture) { @@ -444,7 +444,7 @@ if ($null -ne $WinSDKPath) { } $localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe" -if ((Test-Path variable:ADKDepTools) -and (Test-Path "$ADKDepTools\oscdimg.exe" -PathType leaf)) { +if ((Test-Path variable:ADKDepTools) -and (Test-Path -Path "$ADKDepTools\oscdimg.exe" -PathType Leaf)) { Write-Host "Will be using oscdimg.exe from system ADK." $OSCDIMG = "$ADKDepTools\oscdimg.exe" } else { @@ -452,11 +452,11 @@ if ((Test-Path variable:ADKDepTools) -and (Test-Path "$ADKDepTools\oscdimg.exe" $url = "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe" - if (-not (Test-Path -Path $localOSCDIMGPath)) { + if (-not (Test-Path -Path $localOSCDIMGPath -PathType Leaf)) { Write-Host "Downloading oscdimg.exe..." Invoke-WebRequest -Uri $url -OutFile $localOSCDIMGPath - if (Test-Path $localOSCDIMGPath) { + if (Test-Path -Path $localOSCDIMGPath -PathType Leaf) { Write-Host "oscdimg.exe downloaded successfully." } else { Write-Error "Failed to download oscdimg.exe." From 5fae99b01ec815419089902ebe767477ffa3bd85 Mon Sep 17 00:00:00 2001 From: Snshadow Date: Thu, 16 Jan 2025 10:47:13 +0900 Subject: [PATCH 06/10] enhance: reduce iso image size - Revert to use dism for exporting install.esd to use recovery compression which reduced the size about 1 gigabytes. - Add outlook provisioned appxpackage for removal. --- tiny11Coremaker.ps1 | 2 +- tiny11maker.ps1 | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tiny11Coremaker.ps1 b/tiny11Coremaker.ps1 index 6ac462d..22cb99e 100644 --- a/tiny11Coremaker.ps1 +++ b/tiny11Coremaker.ps1 @@ -122,7 +122,7 @@ $packages = & 'dism' '/English' "/image:$($env:SystemDrive)\scratchdir" '/Get-Pr $matches[1] } } -$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.SecHealthUI_', 'Microsoft.Windows.PeopleExperienceHost_', 'Microsoft.Windows.PinningConfirmationDialog_', 'Windows.CBSPreview_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'MSTeams_', 'Microsoft.549981C3F5F10_' +$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.SecHealthUI_', 'Microsoft.Windows.PeopleExperienceHost_', 'Microsoft.Windows.PinningConfirmationDialog_', 'Windows.CBSPreview_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'MSTeams_', 'Microsoft.549981C3F5F10_', 'Microsoft.OutlookForWindows_' $packagesToRemove = $packages | Where-Object { $packageName = $_ diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index f3f880e..2b4a2c3 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -136,7 +136,7 @@ $packages = Get-ProvisionedAppxPackage -Path "$ScratchDisk\scratchdir" | $_.PackageName } -$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'MSTeams_', 'Microsoft.549981C3F5F10_' +$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'MSTeams_', 'Microsoft.549981C3F5F10_', 'Microsoft.OutlookForWindows_' $packagesToRemove = $packages | Where-Object { $packageName = $_ @@ -387,10 +387,9 @@ Write-Host ' ' Write-Host "Unmounting image..." Dismount-WindowsImage -Path $ScratchDisk\scratchdir -Save Write-Host "Exporting image..." -# Compressiontype Recovery is not supported with PShell https://learn.microsoft.com/en-us/powershell/module/dism/export-windowsimage?view=windowsserver2022-ps#-compressiontype -Export-WindowsImage -SourceImagePath $ScratchDisk\tiny11\sources\install.wim -SourceIndex $index -DestinationImagePath $ScratchDisk\tiny11\sources\install2.wim -CompressionType Maximum +# Compressiontype Recovery is not supported with PShell https://learn.microsoft.com/en-us/powershell/module/dism/export-windowsimage?-ps#-compressiontype +& dism /English /Export-Image "/SourceImageFile:$ScratchDisk\tiny11\sources\install.wim" "/SourceIndex:$index" "/DestinationImageFile:$ScratchDisk\tiny11\sources\install.esd" /Compress:recovery Remove-Item -Path "$ScratchDisk\tiny11\sources\install.wim" -Force | Out-Null -Rename-Item -Path "$ScratchDisk\tiny11\sources\install2.wim" -NewName "install.wim" | Out-Null Write-Host "Windows image completed. Continuing with boot.wim." Start-Sleep -Seconds 2 Clear-Host From 688458d45804e2f53a337dfa56267e06482efbde Mon Sep 17 00:00:00 2001 From: Snshadow Date: Thu, 16 Jan 2025 11:29:09 +0900 Subject: [PATCH 07/10] refactor: add new line for more readable console lines - revert packagePrefixed change as the package is already in github.com/ntdevlabs/tiny11builder/pull/253 --- tiny11Coremaker.ps1 | 2 +- tiny11maker.ps1 | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tiny11Coremaker.ps1 b/tiny11Coremaker.ps1 index 22cb99e..0d19569 100644 --- a/tiny11Coremaker.ps1 +++ b/tiny11Coremaker.ps1 @@ -122,7 +122,7 @@ $packages = & 'dism' '/English' "/image:$($env:SystemDrive)\scratchdir" '/Get-Pr $matches[1] } } -$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.SecHealthUI_', 'Microsoft.Windows.PeopleExperienceHost_', 'Microsoft.Windows.PinningConfirmationDialog_', 'Windows.CBSPreview_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'MSTeams_', 'Microsoft.549981C3F5F10_', 'Microsoft.OutlookForWindows_' +$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.SecHealthUI_', 'Microsoft.Windows.PeopleExperienceHost_', 'Microsoft.Windows.PinningConfirmationDialog_', 'Windows.CBSPreview_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'Microsoft.549981C3F5F10_' $packagesToRemove = $packages | Where-Object { $packageName = $_ diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index 2b4a2c3..0db1dc7 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -129,25 +129,26 @@ if (Test-Path variable:architecture) { } -Write-Host "Mounting complete! Performing removal of applications..." +Write-Host "Mounting complete! Performing removal of applications...`n" $packages = Get-ProvisionedAppxPackage -Path "$ScratchDisk\scratchdir" | ForEach-Object { $_.PackageName } -$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'MSTeams_', 'Microsoft.549981C3F5F10_', 'Microsoft.OutlookForWindows_' +$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'Microsoft.549981C3F5F10_' $packagesToRemove = $packages | Where-Object { $packageName = $_ $packagePrefixes -contains ($packagePrefixes | Where-Object { $packageName -like "$_*" }) } foreach ($package in $packagesToRemove) { - Remove-AppxProvisionedPackage -Path "$ScratchDisk\scratchdir" -PackageName "$package" + Write-Host "Removing $package..." + Remove-AppxProvisionedPackage -Path "$ScratchDisk\scratchdir" -PackageName "$package" | Out-Null } -Write-Host "Removing Edge:" +Write-Host "`nRemoving Edge:" Remove-Item -Path "$ScratchDisk\scratchdir\Program Files (x86)\Microsoft\Edge" -Recurse -Force | Out-Null Remove-Item -Path "$ScratchDisk\scratchdir\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force | Out-Null Remove-Item -Path "$ScratchDisk\scratchdir\Program Files (x86)\Microsoft\EdgeCore" -Recurse -Force | Out-Null From df16ad64f544f356dcf9fbfc38b1bbb925a4588c Mon Sep 17 00:00:00 2001 From: Snshadow Date: Thu, 16 Jan 2025 14:21:11 +0900 Subject: [PATCH 08/10] fix: look for WOW6432Node first - registry value from WOW6432Node is regarded first for setup --- tiny11Coremaker.ps1 | 6 +++++- tiny11maker.ps1 | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tiny11Coremaker.ps1 b/tiny11Coremaker.ps1 index 0d19569..f2934d1 100644 --- a/tiny11Coremaker.ps1 +++ b/tiny11Coremaker.ps1 @@ -733,7 +733,11 @@ Remove-Item "$mainOSDrive\tiny11\sources\install.wim" > $null 2>&1 Write-Host "The tiny11 image is now completed. Proceeding with the making of the ISO..." Write-Host "Creating ISO image..." # Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach). -$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) +$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) +if ($null -eq $WinSDKPath) { + $WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) +} + if ($null -ne $WinSDKPath) { # Trim the following backslash for path concatenation. $WinSDKPath = $WinSDKPath.TrimEnd('\') diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index 0db1dc7..614ae01 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -436,7 +436,11 @@ Write-Host "Copying unattended file for bypassing MS account on OOBE..." Copy-Item -Path "$PSScriptRoot\autounattend.xml" -Destination "$ScratchDisk\tiny11\autounattend.xml" -Force | Out-Null Write-Host "Creating ISO image..." # Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach). -$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) +$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) +if ($null -eq $WinSDKPath) { + $WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) +} + if ($null -ne $WinSDKPath) { # Trim the following backslash for path concatenation. $WinSDKPath = $WinSDKPath.TrimEnd('\') From a5864da64cdc46c49551a5041f726794a7ddf43b Mon Sep 17 00:00:00 2001 From: Snshadow Date: Sun, 6 Apr 2025 21:22:29 +0900 Subject: [PATCH 09/10] fix: ScratchDisk variable and some more.. - fix (noted in https://github.com/ntdevlabs/tiny11builder/issues/339) by adding ':' colon for validation pattern, which used to be set to empty value(resulting in using script root path) - use `Export-WindowsImage` with undocumented Compression Type for more consistence - use direct string check for little performance improvement --- tiny11maker.ps1 | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index 614ae01..729f3d7 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -2,12 +2,12 @@ #Set-PSDebug -Trace 1 param ( - [ValidatePattern('^[c-zC-Z]$')] + [ValidatePattern('^[c-zC-Z]:$')] [string]$ScratchDisk ) if (-not $ScratchDisk) { - $ScratchDisk = $PSScriptRoot -replace '[\\]+$', '' + $ScratchDisk = ((Get-Location).Drive.Name) + ":" } else { $ScratchDisk = $ScratchDisk + ":" } @@ -44,8 +44,6 @@ if (! $myWindowsPrincipal.IsInRole($adminRole)) exit } - - # Start the transcript and prepare the window Start-Transcript -Path "$ScratchDisk\tiny11.log" @@ -122,7 +120,7 @@ switch ((Get-WindowsImage -ImagePath $wimFilePath -Index $index).Architecture) 12 { $architecture = "arm64" } } -if (Test-Path variable:architecture) { +if ($architecture) { Write-Host "Architecture: $architecture" } else { Write-Host "Architecture information not found." @@ -388,9 +386,9 @@ Write-Host ' ' Write-Host "Unmounting image..." Dismount-WindowsImage -Path $ScratchDisk\scratchdir -Save Write-Host "Exporting image..." -# Compressiontype Recovery is not supported with PShell https://learn.microsoft.com/en-us/powershell/module/dism/export-windowsimage?-ps#-compressiontype -& dism /English /Export-Image "/SourceImageFile:$ScratchDisk\tiny11\sources\install.wim" "/SourceIndex:$index" "/DestinationImageFile:$ScratchDisk\tiny11\sources\install.esd" /Compress:recovery -Remove-Item -Path "$ScratchDisk\tiny11\sources\install.wim" -Force | Out-Null +# Run `Export-WindowsImage` with undocumented CompressionType "LZMS" (which is the same compression used for Recovery from dism.exe) +Export-WindowsImage -SourceImagePath "$ScratchDisk\tiny11\sources\install.wim" -SourceIndex "$index" -DestinationImagePath "$ScratchDisk\tiny11\sources\install2.wim" -CompressionType "LZMS" +Move-Item -Path "$ScratchDisk\tiny11\sources\install2.wim" -Destination "$ScratchDisk\tiny11\sources\install.wim" -Force | Out-Null Write-Host "Windows image completed. Continuing with boot.wim." Start-Sleep -Seconds 2 Clear-Host @@ -437,18 +435,18 @@ Copy-Item -Path "$PSScriptRoot\autounattend.xml" -Destination "$ScratchDisk\tiny Write-Host "Creating ISO image..." # Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach). $WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) -if ($null -eq $WinSDKPath) { +if (!$WinSDKPath) { $WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null) } -if ($null -ne $WinSDKPath) { +if ($WinSDKPath) { # Trim the following backslash for path concatenation. $WinSDKPath = $WinSDKPath.TrimEnd('\') $ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" } $localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe" -if ((Test-Path variable:ADKDepTools) -and (Test-Path -Path "$ADKDepTools\oscdimg.exe" -PathType Leaf)) { +if ($ADKDepTools -and [System.IO.File]::Exists("$ADKDepTools\oscdimg.exe")) { Write-Host "Will be using oscdimg.exe from system ADK." $OSCDIMG = "$ADKDepTools\oscdimg.exe" } else { @@ -456,11 +454,11 @@ if ((Test-Path variable:ADKDepTools) -and (Test-Path -Path "$ADKDepTools\oscdimg $url = "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe" - if (-not (Test-Path -Path $localOSCDIMGPath -PathType Leaf)) { + if (![System.IO.File]::Exists($localOSCDIMGPath)) { Write-Host "Downloading oscdimg.exe..." Invoke-WebRequest -Uri $url -OutFile $localOSCDIMGPath - if (Test-Path -Path $localOSCDIMGPath -PathType Leaf) { + if ([System.IO.File]::Exists($localOSCDIMGPath)) { Write-Host "oscdimg.exe downloaded successfully." } else { Write-Error "Failed to download oscdimg.exe." From e094eff295149b74b12596872c12812577e0242e Mon Sep 17 00:00:00 2001 From: Snshadow <89772726+Snshadow@users.noreply.github.com> Date: Thu, 11 Sep 2025 08:43:37 +0900 Subject: [PATCH 10/10] fix: Instruction list number --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b03f416..88f03e2 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@ This script generates a significantly reduced Windows 11 image. However, **it's 1. Download Windows 11 from the [Microsoft website](https://www.microsoft.com/software-download/windows11) or [Rufus](https://github.com/pbatard/rufus) 2. Mount the downloaded ISO image using Windows Explorer. 3. Open **PowerShell 5.1** as Administrator. -5. Change the script execution policy : +4. Change the script execution policy : ```powershell Set-ExecutionPolicy Bypass -Scope Process ``` > Using `-Scope Process` you keep your original policy intact as this change only lasts for the current PowerShell session. -6. Start the script : +5. Start the script : ```powershell C:/path/to/your/tiny11/script.ps1 -ISO -SCRATCH ```