mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-29 01:11:30 -06:00
Improve copy operation to Ventoy drives
This change may fix the issues where there's a conflict between both Ventoy's and MicroWin's unattended answer files, causing target images to stop working as expected during OOBE
This commit is contained in:
parent
9979a02a30
commit
3cfc7c92b4
@ -16,6 +16,54 @@ function Microwin-CopyToUSB([string]$fileToCopy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "File copied to Ventoy drive $($volume.DriveLetter)"
|
Write-Host "File copied to Ventoy drive $($volume.DriveLetter)"
|
||||||
|
|
||||||
|
# Detect if config files are present, move them if they are, and configure the Ventoy drive to not bypass the requirements
|
||||||
|
$customVentoyConfig = @'
|
||||||
|
{
|
||||||
|
"control":[
|
||||||
|
{ "VTOY_WIN11_BYPASS_CHECK": "0" },
|
||||||
|
{ "VTOY_WIN11_BYPASS_NRO": "0" }
|
||||||
|
],
|
||||||
|
"control_legacy":[
|
||||||
|
{ "VTOY_WIN11_BYPASS_CHECK": "0" },
|
||||||
|
{ "VTOY_WIN11_BYPASS_NRO": "0" }
|
||||||
|
],
|
||||||
|
"control_uefi":[
|
||||||
|
{ "VTOY_WIN11_BYPASS_CHECK": "0" },
|
||||||
|
{ "VTOY_WIN11_BYPASS_NRO": "0" }
|
||||||
|
],
|
||||||
|
"control_ia32":[
|
||||||
|
{ "VTOY_WIN11_BYPASS_CHECK": "0" },
|
||||||
|
{ "VTOY_WIN11_BYPASS_NRO": "0" }
|
||||||
|
],
|
||||||
|
"control_aa64":[
|
||||||
|
{ "VTOY_WIN11_BYPASS_CHECK": "0" },
|
||||||
|
{ "VTOY_WIN11_BYPASS_NRO": "0" }
|
||||||
|
],
|
||||||
|
"control_mips":[
|
||||||
|
{ "VTOY_WIN11_BYPASS_CHECK": "0" },
|
||||||
|
{ "VTOY_WIN11_BYPASS_NRO": "0" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
'@
|
||||||
|
|
||||||
|
try {
|
||||||
|
Write-Host "Writing custom Ventoy configuration. Please wait..."
|
||||||
|
if (Test-Path -Path "$($volume.DriveLetter):\ventoy\ventoy.json" -PathType Leaf) {
|
||||||
|
Write-Host "A Ventoy configuration file exists. Moving it..."
|
||||||
|
Move-Item -Path "$($volume.DriveLetter):\ventoy\ventoy.json" -Destination "$($volume.DriveLetter):\ventoy\ventoy.json.old" -Force
|
||||||
|
Write-Host "Existing Ventoy configuration has been moved to `"ventoy.json.old`". Feel free to put your config back into the `"ventoy.json`" file."
|
||||||
|
}
|
||||||
|
if (-not (Test-Path -Path "$($volume.DriveLetter):\ventoy")) {
|
||||||
|
New-Item -Path "$($volume.DriveLetter):\ventoy" -ItemType Directory -Force | Out-Null
|
||||||
|
}
|
||||||
|
$customVentoyConfig | Out-File -FilePath "$($volume.DriveLetter):\ventoy\ventoy.json" -Encoding utf8 -Force
|
||||||
|
Write-Host "The Ventoy drive has been successfully configured."
|
||||||
|
} catch {
|
||||||
|
Write-Host "Could not configure Ventoy drive. Error: $($_.Exception.Message)`n"
|
||||||
|
Write-Host "Be sure to add the following configuration to the Ventoy drive by either creating a `"ventoy.json`" file in the `"ventoy`" directory (create it if it doesn't exist) or by editing an existing one: `n`n$customVentoyConfig`n"
|
||||||
|
Write-Host "Failure to do this will cause conflicts with your target ISO file."
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user