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"