mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-12 16:00:37 -06:00
9183e92692
* Set Boot Manager entry timeout to 0 Fixes #2562 * Exclude Windows Hello stuff from package removal * Obscure passwords with Base64 and fix indentation Fixes #3064 * Fix name of excluded package * Update comment It reflects my feelings towards Microsoft when it comes to security a lot better * Remove jargon of scratch directory options * Package exclusion improvements - Removed AppX packages from OS package exclusion list - Added exclusion of PowerShell ISE (source: Discord server - yes, some people still use the PowerShell ISE) * Exclude Windows Photo Viewer from dir removal * 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 * Add VirtIO functionality and more enhancements - Added the ability to grab VirtIO Guest Tools - Modified the description of the Copy ISO files function because it basically had nonsense * Fix typo (#3104) * Access specific property of ISO image object Only show the ISO path. No one is interested in the storage type * Add detections for expedited app removal They only affect 24H2 and newer. Earlier releases don't have these expedited apps * Update message * Add VirtIO instructions to MicroWin page * Add DISM command fallback This fallback is triggered if an exception occurs while getting information with the cmdlets (I couldn't test this on my host as everything magically works now - sometimes it threw the Class not registered error) * Exclude OpenSSH from package removal Some people need this to avoid installing third-party programs like PuTTY * Fixed some more indentation
72 lines
3.4 KiB
PowerShell
72 lines
3.4 KiB
PowerShell
function Microwin-CopyToUSB([string]$fileToCopy) {
|
|
foreach ($volume in Get-Volume) {
|
|
if ($volume -and $volume.FileSystemLabel -ieq "ventoy") {
|
|
$destinationPath = "$($volume.DriveLetter):\"
|
|
#Copy-Item -Path $fileToCopy -Destination $destinationPath -Force
|
|
# Get the total size of the file
|
|
$totalSize = (Get-Item "$fileToCopy").length
|
|
|
|
Copy-Item -Path "$fileToCopy" -Destination "$destinationPath" -Verbose -Force -Recurse -Container -PassThru |
|
|
ForEach-Object {
|
|
# Calculate the percentage completed
|
|
$completed = ($_.BytesTransferred / $totalSize) * 100
|
|
|
|
# Display the progress bar
|
|
Write-Progress -Activity "Copying File" -Status "Progress" -PercentComplete $completed -CurrentOperation ("{0:N2} MB / {1:N2} MB" -f ($_.BytesTransferred / 1MB), ($totalSize / 1MB))
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
Write-Host "Ventoy USB Key is not inserted"
|
|
}
|