mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-10-08 11:39:10 +11:00
Fix OSCDIMG detection (#4983)
* fix: detect machine-wide OSCDIMG installations * fix: repeat OSCDIMG discovery after installation
This commit is contained in:
@@ -529,6 +529,34 @@ function Invoke-WinUtilISOCleanAndReset {
|
|||||||
$script.BeginInvoke()
|
$script.BeginInvoke()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Get-WinUtilOSCDImgPath {
|
||||||
|
# Windows ADK installation
|
||||||
|
$oscdimg = Get-ChildItem "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
|
||||||
|
Select-Object -First 1 -ExpandProperty FullName
|
||||||
|
if (-not $oscdimg) {
|
||||||
|
# Per-user winget installation
|
||||||
|
$oscdimg = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WinGet\Packages" -Recurse -Filter "oscdimg.exe" -ErrorAction SilentlyContinue |
|
||||||
|
Where-Object { $_.FullName -match 'Microsoft\.OSCDIMG' } |
|
||||||
|
Select-Object -First 1 -ExpandProperty FullName
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $oscdimg) {
|
||||||
|
# Installation available through the current process PATH
|
||||||
|
$oscdimg = Get-Command oscdimg.exe -CommandType Application -ErrorAction SilentlyContinue |
|
||||||
|
Select-Object -First 1 -ExpandProperty Source
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $oscdimg) {
|
||||||
|
# WinGet links that may not yet be available through the current process PATH
|
||||||
|
$oscdimg = @(
|
||||||
|
"$env:LOCALAPPDATA\Microsoft\WinGet\Links\oscdimg.exe"
|
||||||
|
"$env:ProgramFiles\WinGet\Links\oscdimg.exe"
|
||||||
|
) | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return $oscdimg
|
||||||
|
}
|
||||||
|
|
||||||
function Invoke-WinUtilISOExport {
|
function Invoke-WinUtilISOExport {
|
||||||
$contentsDir = $sync["Win11ISOContentsDir"]
|
$contentsDir = $sync["Win11ISOContentsDir"]
|
||||||
|
|
||||||
@@ -551,14 +579,7 @@ function Invoke-WinUtilISOExport {
|
|||||||
|
|
||||||
$outputISO = $dlg.FileName
|
$outputISO = $dlg.FileName
|
||||||
|
|
||||||
# Locate oscdimg.exe (Windows ADK or winget per-user install)
|
$oscdimg = Get-WinUtilOSCDImgPath
|
||||||
$oscdimg = Get-ChildItem "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "oscdimg.exe" |
|
|
||||||
Select-Object -First 1 -ExpandProperty FullName
|
|
||||||
if (-not $oscdimg) {
|
|
||||||
$oscdimg = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WinGet\Packages" -Recurse -Filter "oscdimg.exe" |
|
|
||||||
Where-Object { $_.FullName -match 'Microsoft\.OSCDIMG' } |
|
|
||||||
Select-Object -First 1 -ExpandProperty FullName
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not $oscdimg) {
|
if (-not $oscdimg) {
|
||||||
Write-WinUtilISOLog "oscdimg.exe not found. Attempting to install via winget..."
|
Write-WinUtilISOLog "oscdimg.exe not found. Attempting to install via winget..."
|
||||||
@@ -569,9 +590,7 @@ function Invoke-WinUtilISOExport {
|
|||||||
$winget = Get-Command winget
|
$winget = Get-Command winget
|
||||||
$result = & $winget install -e --id Microsoft.OSCDIMG --accept-package-agreements --accept-source-agreements
|
$result = & $winget install -e --id Microsoft.OSCDIMG --accept-package-agreements --accept-source-agreements
|
||||||
Write-WinUtilISOLog "winget output: $result"
|
Write-WinUtilISOLog "winget output: $result"
|
||||||
$oscdimg = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WinGet\Packages" -Recurse -Filter "oscdimg.exe" |
|
$oscdimg = Get-WinUtilOSCDImgPath
|
||||||
Where-Object { $_.FullName -match 'Microsoft\.OSCDIMG' } |
|
|
||||||
Select-Object -First 1 -ExpandProperty FullName
|
|
||||||
} catch {
|
} catch {
|
||||||
Write-WinUtilISOLog "winget not available or install failed: $_"
|
Write-WinUtilISOLog "winget not available or install failed: $_"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user