Carsten
Carsten

Reputation: 2191

How to extract oscdimg.exe from ADK CAB-file?

I have a project where I need to download the oscdimg.exe tool from the Windows 11 ASK. For this I have written this small PS-code which is doing the job, but it still uses the filesystem to store the interim CAB-file. Is there any way to do the extraction directly on the byte-array of the CAB-file in memory (e.g. via [System.IO.Compression])?

# download oscdimg-tool from Windows 11 ADK:

$tmp  = $env:temp
$cab  = '5d984200acbde182fd99cbfbe9bad133.cab'
$fil  = 'fil720cc132fbb53f3bed2e525eb77bdbc1'
$exe  = 'oscdimg.exe'
$adk  = "https://download.microsoft.com/download/1/f/d/1fd2291e-c0e9-4ae0-beae-fbbe0fe41a5a/adk/Installers/$cab"

if (!(Test-Path -Path "$tmp\$exe" -PathType Leaf)) {
    $null= Invoke-WebRequest $adk -OutFile "$tmp\$cab"
    $app = new-object -com shell.application
    $in  = $app.NameSpace("$tmp\$cab")
    $out = $app.NameSpace($tmp)
    $itm = $in.Items() | where {$_.Name -eq $fil}
    $out.CopyHere($itm, 16)
    Rename-Item "$tmp\$fil" "$exe" -ea 0
    Remove-Item "$tmp\$cab"
}

Upvotes: 0

Views: 875

Answers (0)

Related Questions