Skip to content

Commit e1273fe

Browse files
committed
fix: do not call method on $null object
- fix the cause of crash if ADK is not installed
1 parent b0750f3 commit e1273fe

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

tiny11Coremaker.ps1

+4-2
Original file line numberDiff line numberDiff line change
@@ -732,9 +732,11 @@ Write-Host "Exporting ESD. This may take a while..."
732732
Remove-Item "$mainOSDrive\tiny11\sources\install.wim" > $null 2>&1
733733
Write-Host "The tiny11 image is now completed. Proceeding with the making of the ISO..."
734734
Write-Host "Creating ISO image..."
735-
# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach), trim the following backslash for path concatenation.
736-
$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null).TrimEnd('\')
735+
# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach).
736+
$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null)
737737
if ($null -ne $WinSDKPath) {
738+
# Trim the following backslash for path concatenation.
739+
$WinSDKPath = $WinSDKPath.TrimEnd('\')
738740
$ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg"
739741
}
740742
$localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe"

tiny11maker.ps1

+4-2
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,11 @@ Write-Host "The tiny11 image is now completed. Proceeding with the making of the
438438
Write-Host "Copying unattended file for bypassing MS account on OOBE..."
439439
Copy-Item -Path "$PSScriptRoot\autounattend.xml" -Destination "$ScratchDisk\tiny11\autounattend.xml" -Force | Out-Null
440440
Write-Host "Creating ISO image..."
441-
# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach), trim the following backslash for path concatenation.
442-
$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null).TrimEnd('\')
441+
# Get Windows ADK path from registry(following Visual Studio's winsdk.bat approach).
442+
$WinSDKPath = [Microsoft.Win32.Registry]::GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots", "KitsRoot10", $null)
443443
if ($null -ne $WinSDKPath) {
444+
# Trim the following backslash for path concatenation.
445+
$WinSDKPath = $WinSDKPath.TrimEnd('\')
444446
$ADKDepTools = "$WinSDKPath\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg"
445447
}
446448
$localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe"

0 commit comments

Comments
 (0)