Skip to content

Commit 49dac34

Browse files
committed
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.
1 parent af69a48 commit 49dac34

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can now use it on ANY Windows 11 release (not just a specific build), as wel
1010
This is made possible thanks to the much-improved scripting capabilities of PowerShell, compared to the older Batch release.
1111
</br>
1212
Since it is written in PowerShell, you need to set the execution policy to `Unrestricted`, so that you could run the script.
13-
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.
13+
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.
1414

1515

1616
This is a script created to automate the build of a streamlined Windows 11 image, similar to tiny11.

Run.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
:: Reference from https://github.com/Raphire/Win11Debloat/blob/master/Run.bat licensed under MIT license.
2+
3+
@echo off
4+
5+
Powershell -ExecutionPolicy Bypass -Command "& {Start-Process Powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dp0tiny11maker.ps1""' -Verb RunAs}"

tiny11Coremaker.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -730,16 +730,19 @@ Write-Host "Exporting ESD. This may take a while..."
730730
Remove-Item "$mainOSDrive\tiny11\sources\install.wim" > $null 2>&1
731731
Write-Host "The tiny11 image is now completed. Proceeding with the making of the ISO..."
732732
Write-Host "Creating ISO image..."
733-
$ADKDepTools = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg"
733+
# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach), trim the following backslash for path concatenation.
734+
$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null).TrimEnd('\')
735+
if ($null -ne $WinSDKPath) {
736+
$ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg"
737+
}
734738
$localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe"
735739

736-
if ([System.IO.Directory]::Exists($ADKDepTools)) {
740+
if ((Test-Path variable:ADKDepTools) -and (Test-Path "$ADKDepTools\oscdimg.exe" -PathType leaf)) {
737741
Write-Host "Will be using oscdimg.exe from system ADK."
738742
$OSCDIMG = "$ADKDepTools\oscdimg.exe"
739743
} else {
740-
Write-Host "ADK folder not found. Will be using bundled oscdimg.exe."
741-
742-
744+
Write-Host "oscdimg.exe from system ADK not found. Will be using bundled oscdimg.exe."
745+
743746
$url = "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe"
744747

745748
if (-not (Test-Path -Path $localOSCDIMGPath)) {

tiny11maker.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,14 +436,18 @@ Write-Host "The tiny11 image is now completed. Proceeding with the making of the
436436
Write-Host "Copying unattended file for bypassing MS account on OOBE..."
437437
Copy-Item -Path "$PSScriptRoot\autounattend.xml" -Destination "$ScratchDisk\tiny11\autounattend.xml" -Force | Out-Null
438438
Write-Host "Creating ISO image..."
439-
$ADKDepTools = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg"
439+
# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach), trim the following backslash for path concatenation.
440+
$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null).TrimEnd('\')
441+
if ($null -ne $WinSDKPath) {
442+
$ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg"
443+
}
440444
$localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe"
441445

442-
if ([System.IO.Directory]::Exists($ADKDepTools)) {
446+
if ((Test-Path variable:ADKDepTools) -and (Test-Path "$ADKDepTools\oscdimg.exe" -PathType leaf)) {
443447
Write-Host "Will be using oscdimg.exe from system ADK."
444448
$OSCDIMG = "$ADKDepTools\oscdimg.exe"
445449
} else {
446-
Write-Host "ADK folder not found. Will be using bundled oscdimg.exe."
450+
Write-Host "oscdimg.exe from system ADK not found. Will be using bundled oscdimg.exe."
447451

448452
$url = "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe"
449453

0 commit comments

Comments
 (0)