tiny11builder icon indicating copy to clipboard operation
tiny11builder copied to clipboard

[suggestion] Better instructions to get oscdimg.exe directly from Microsoft

Open Rust1667 opened this issue 2 years ago • 5 comments

I think you could add these details so that people can get that .exe from Microsoft (to calm down possible controversies created by that CTT video). I used that .exe this way and it worked for me.

1 Download Windows ADK Package located @ https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install 2 Install. During installation of Windows ADK, you only need to tick the part of the package called "Deployment Tools" to get the file. 3 After it's installed, you can find oscdimg.exe here: C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg

Rust1667 avatar Apr 08 '23 12:04 Rust1667

I should imagine it would be possible to automate the download process directly from Microsoft https://github.com/ntdevlabs/tiny11builder/pull/43#issuecomment-1501074660

PolicyPuma4 avatar Apr 09 '23 08:04 PolicyPuma4

I like WGET (it's my preference, maybe because it's GNU); that said, CURL would also work. Here is with WGET: wget https://go.microsoft.com/fwlink/?linkid=2196127 --output-document adksetup.exe

You can do a simple check with wget --version 2> nul SET $WGET_STATUS=%ERRORLEVEL%

...anything other than 0 it's not installed.

If the client doesn't have wget, provide the option to download from Chocolatey or winget . winget install "Wget"

Much of this code is available on my Dell Command Update module.

DavidGeeraerts avatar Apr 11 '23 15:04 DavidGeeraerts

I like WGET (it's my preference, maybe because it's GNU); that said, CURL would also work. Here is with WGET: wget https://go.microsoft.com/fwlink/?linkid=2196127 --output-document adksetup.exe

You can do a simple check with wget --version 2> nul SET $WGET_STATUS=%ERRORLEVEL%

...anything other than 0 it's not installed.

If the client doesn't have wget, provide the option to download from Chocolatey or winget . winget install "Wget"

Much of this code is available on my Dell Command Update module.

Wget is usually my go to when simply downloading files, however I used cURL because it's available without PowerShell on any Windows version later than 1803 (end of life). The batch script I mentioned downloads only the Oscdimg binary directly from Microsoft, which bypasses the requirement of having to download and install Windows ADK all together.

PolicyPuma4 avatar Apr 11 '23 16:04 PolicyPuma4

When I try to get the file via ADK Install I get this error

WinADK_Install_Error

Bioanalytica avatar Dec 03 '23 22:12 Bioanalytica

I don't use tiny11builder. I have stumbled upon this issue while searching for something else. :wink:

I created a PowerShell script to get the unattend XSD schema from Windows ADK which first installs it, therefore it should fix this issue. You might want to modify (you can freely do it).

The script is as follows. If you don't want to get the unattend XSD schema, you can remove the $out variable definition and skip all commands after # NOTE: STOP HERE IF YOU DON'T WANT TO EXTRACT THE UNATTEND XSD SCHEMA. and you should add a different clean-up command: Remove-Item "$env:TEMP\adksetup.exe", "$env:TEMP\dotnet_4.7.2_dev_pack.exe".

Extract-XsdSchema.ps1
# Extract unattend XSD schema from Windows ADK


# Define where the XSD schema should be saved, incl the filename
$out = "$PSScriptRoot\..\unattended_config\schema\unattend_win_10.xsd"

# Download Windows ADK 10.1.25398.1
Write-Output 'Downloading Windows ADK ...'

$adksetup = Start-BitsTransfer 'https://go.microsoft.com/fwlink/?linkid=2243390' -Destination "$env:TEMP\adksetup.exe"

switch ($adksetup.JobState) {
  'Transferred' {
    Complete-BitsTransfer -BitsJob $adksetup
    Write-Output 'Windows ADK downloaded.'
    break
  }

  'Error' {
    throw 'Error downloading Windows ADK.'
  }
}

# Download .NET Framework 4.7.2 Developer Pack
Write-Output 'Downloading .NET Framework 4.7.2 Developer Pack ...'

$dotnet = Start-BitsTransfer 'https://go.microsoft.com/fwlink/?linkid=2243390' -Destination "$env:TEMP\dotnet_4.7.2_dev_pack.exe"

switch ($dotnet.JobState) {
  'Transferred' {
    Complete-BitsTransfer -BitsJob $dotnet
    Write-Output '.NET Framework 4.7.2 Developer Pack downloaded.'
    break
  }

  'Error' {
    throw 'Error downloading .NET Framework 4.7.2 Developer Pack.'
  }
}

# Install Deployment Tools feature from Windows ADK
Write-Output 'Installing Windows ADK ...'
Start-Process -Wait "$env:TEMP\adksetup.exe" -ArgumentList '/q /features OptionId.DeploymentTools /norestart /ceip off'
Write-Output 'Windows ADK installed.'

# Install .NET Framework 4.7.2 Developer Pack
Write-Output 'Installing .NET Framework 4.7.2 Developer Pack ...'
Start-Process -Wait "$env:TEMP\dotnet_4.7.2_dev_pack.exe"
Write-Output '.NET Framework 4.7.2 Developer Pack installed.'

# NOTE: STOP HERE IF YOU DON'T WANT TO EXTRACT THE UNATTEND XSD SCHEMA.

if (!(Test-Path "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\ildasm.exe" -PathType Leaf)) {
  throw 'Could not find `ildasm.exe`.'
}

if (!(Test-Path "${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\WSIM\amd64\microsoft.componentstudio.componentplatforminterface.dll" -PathType Leaf)) {
  throw 'Could not find `microsoft.componentstudio.componentplatforminterface.dll`.'
}

# Extract the resources embedded in `microsoft.componentstudio.componentplatforminterface.dll`
Write-Output 'Extracting the XSD schema embedded in `microsoft.componentstudio.componentplatforminterface.dll`'
& "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\ildasm.exe" "${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\WSIM\amd64\microsoft.componentstudio.componentplatforminterface.dll" /Output="$env:TEMP\out.il"

if (!(Test-Path "$env:TEMP\Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources" -PathType Leaf)) {
  throw 'Could not find `Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources`.'
}

# Get content from the input file
$fileContent = Get-Content -Path "$env:TEMP\Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources" -Raw

# Regular expression (Regex) of the given start and end patterns
$pattern = '(?is)({0}.*?{1})' -f [regex]::Escape('<?xml version='), [regex]::Escape('</xsd:schema>')

# Perform the Regex operation and save it to file
[regex]::Match($fileContent, $pattern).Groups[1].Value | Set-Content -Path "$out"

if (!(Test-Path "$out" -PathType Leaf)) {
  throw "Could not find `$out`."
}

Write-Output 'The XSD schema extracted.'

# Clean up
Remove-Item "$env:TEMP\Microsoft.ComponentStudio.ComponentPlatformInterface.DistributionShareResources.resources", "$env:TEMP\Microsoft.ComponentStudio.ComponentPlatformInterface.MyResources.resources", "$env:TEMP\adksetup.exe", "$env:TEMP\dotnet_4.7.2_dev_pack.exe", "$env:TEMP\out.il", "$env:TEMP\out.res"

tukusejssirs avatar Jan 06 '24 20:01 tukusejssirs