mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
Add quotes to paths (#2552)
Fixes reported issues about paths with spaces
This commit is contained in:
parent
5994105fba
commit
41ac93d09a
@ -157,7 +157,7 @@ function Remove-ProvisionedPackages([switch]$keepSecurity = $false) {
|
|||||||
$status = "Removing Provisioned $($appx.PackageName)"
|
$status = "Removing Provisioned $($appx.PackageName)"
|
||||||
Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100)
|
Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100)
|
||||||
try {
|
try {
|
||||||
Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName -ErrorAction SilentlyContinue
|
Remove-AppxProvisionedPackage -Path "$scratchDir" -PackageName $appx.PackageName -ErrorAction SilentlyContinue
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "Application $($appx.PackageName) could not be removed"
|
Write-Host "Application $($appx.PackageName) could not be removed"
|
||||||
continue
|
continue
|
||||||
@ -175,9 +175,9 @@ function Copy-ToUSB([string]$fileToCopy) {
|
|||||||
$destinationPath = "$($volume.DriveLetter):\"
|
$destinationPath = "$($volume.DriveLetter):\"
|
||||||
#Copy-Item -Path $fileToCopy -Destination $destinationPath -Force
|
#Copy-Item -Path $fileToCopy -Destination $destinationPath -Force
|
||||||
# Get the total size of the file
|
# Get the total size of the file
|
||||||
$totalSize = (Get-Item $fileToCopy).length
|
$totalSize = (Get-Item "$fileToCopy").length
|
||||||
|
|
||||||
Copy-Item -Path $fileToCopy -Destination $destinationPath -Verbose -Force -Recurse -Container -PassThru |
|
Copy-Item -Path "$fileToCopy" -Destination "$destinationPath" -Verbose -Force -Recurse -Container -PassThru |
|
||||||
ForEach-Object {
|
ForEach-Object {
|
||||||
# Calculate the percentage completed
|
# Calculate the percentage completed
|
||||||
$completed = ($_.BytesTransferred / $totalSize) * 100
|
$completed = ($_.BytesTransferred / $totalSize) * 100
|
||||||
|
@ -76,7 +76,7 @@ function Invoke-WPFGetIso {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "File path $($filePath)"
|
Write-Host "File path $($filePath)"
|
||||||
if (-not (Test-Path -Path $filePath -PathType Leaf)) {
|
if (-not (Test-Path -Path "$filePath" -PathType Leaf)) {
|
||||||
$msg = "File you've chosen doesn't exist"
|
$msg = "File you've chosen doesn't exist"
|
||||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||||
return
|
return
|
||||||
@ -85,7 +85,7 @@ function Invoke-WPFGetIso {
|
|||||||
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo"
|
||||||
|
|
||||||
# Detect the file size of the ISO and compare it with the free space of the system drive
|
# Detect the file size of the ISO and compare it with the free space of the system drive
|
||||||
$isoSize = (Get-Item -Path $filePath).Length
|
$isoSize = (Get-Item -Path "$filePath").Length
|
||||||
Write-Debug "Size of ISO file: $($isoSize) bytes"
|
Write-Debug "Size of ISO file: $($isoSize) bytes"
|
||||||
# Use this procedure to get the free space of the drive depending on where the user profile folder is stored.
|
# Use this procedure to get the free space of the drive depending on where the user profile folder is stored.
|
||||||
# This is done to guarantee a dynamic solution, as the installation drive may be mounted to a letter different than C
|
# This is done to guarantee a dynamic solution, as the installation drive may be mounted to a letter different than C
|
||||||
@ -122,7 +122,7 @@ function Invoke-WPFGetIso {
|
|||||||
# there is probably a better way of doing this, I don't have time to figure this out
|
# there is probably a better way of doing this, I don't have time to figure this out
|
||||||
$sync.MicrowinIsoDrive.Text = $driveLetter
|
$sync.MicrowinIsoDrive.Text = $driveLetter
|
||||||
|
|
||||||
$mountedISOPath = (Split-Path -Path $filePath)
|
$mountedISOPath = (Split-Path -Path "$filePath")
|
||||||
if ($sync.MicrowinScratchDirBox.Text.Trim() -eq "Scratch") {
|
if ($sync.MicrowinScratchDirBox.Text.Trim() -eq "Scratch") {
|
||||||
$sync.MicrowinScratchDirBox.Text =""
|
$sync.MicrowinScratchDirBox.Text =""
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ function Invoke-WPFGetIso {
|
|||||||
$wimFile = "$mountDir\sources\install.wim"
|
$wimFile = "$mountDir\sources\install.wim"
|
||||||
Write-Host "Getting image information $wimFile"
|
Write-Host "Getting image information $wimFile"
|
||||||
|
|
||||||
if ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (-not (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf))) {
|
if ((-not (Test-Path -Path "$wimFile" -PathType Leaf)) -and (-not (Test-Path -Path "$($wimFile.Replace(".wim", ".esd").Trim())" -PathType Leaf))) {
|
||||||
$msg = "Neither install.wim nor install.esd exist in the image, this could happen if you use unofficial Windows images. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/"
|
$msg = "Neither install.wim nor install.esd exist in the image, this could happen if you use unofficial Windows images. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/"
|
||||||
Write-Host $msg
|
Write-Host $msg
|
||||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
||||||
|
@ -63,11 +63,11 @@ public class PowerManagement {
|
|||||||
$scratchDir = $sync.MicrowinScratchDir.Text
|
$scratchDir = $sync.MicrowinScratchDir.Text
|
||||||
|
|
||||||
# Detect if the Windows image is an ESD file and convert it to WIM
|
# Detect if the Windows image is an ESD file and convert it to WIM
|
||||||
if (-not (Test-Path -Path $mountDir\sources\install.wim -PathType Leaf) -and (Test-Path -Path $mountDir\sources\install.esd -PathType Leaf)) {
|
if (-not (Test-Path -Path "$mountDir\sources\install.wim" -PathType Leaf) -and (Test-Path -Path "$mountDir\sources\install.esd" -PathType Leaf)) {
|
||||||
Write-Host "Exporting Windows image to a WIM file, keeping the index we want to work on. This can take several minutes, depending on the performance of your computer..."
|
Write-Host "Exporting Windows image to a WIM file, keeping the index we want to work on. This can take several minutes, depending on the performance of your computer..."
|
||||||
Export-WindowsImage -SourceImagePath $mountDir\sources\install.esd -SourceIndex $index -DestinationImagePath $mountDir\sources\install.wim -CompressionType "Max"
|
Export-WindowsImage -SourceImagePath $mountDir\sources\install.esd -SourceIndex $index -DestinationImagePath $mountDir\sources\install.wim -CompressionType "Max"
|
||||||
if ($?) {
|
if ($?) {
|
||||||
Remove-Item -Path $mountDir\sources\install.esd -Force
|
Remove-Item -Path "$mountDir\sources\install.esd" -Force
|
||||||
# Since we've already exported the image index we wanted, switch to the first one
|
# Since we've already exported the image index we wanted, switch to the first one
|
||||||
$index = 1
|
$index = 1
|
||||||
} else {
|
} else {
|
||||||
@ -116,7 +116,7 @@ public class PowerManagement {
|
|||||||
if (Test-Path "$env:TEMP\DRV_EXPORT") {
|
if (Test-Path "$env:TEMP\DRV_EXPORT") {
|
||||||
Remove-Item "$env:TEMP\DRV_EXPORT" -Recurse -Force
|
Remove-Item "$env:TEMP\DRV_EXPORT" -Recurse -Force
|
||||||
}
|
}
|
||||||
if (($injectDrivers -and (Test-Path $sync.MicrowinDriverLocation.Text))) {
|
if (($injectDrivers -and (Test-Path "$($sync.MicrowinDriverLocation.Text)"))) {
|
||||||
Write-Host "Using specified driver source..."
|
Write-Host "Using specified driver source..."
|
||||||
dism /english /online /export-driver /destination="$($sync.MicrowinDriverLocation.Text)" | Out-Host
|
dism /english /online /export-driver /destination="$($sync.MicrowinDriverLocation.Text)" | Out-Host
|
||||||
if ($?) {
|
if ($?) {
|
||||||
@ -341,7 +341,7 @@ public class PowerManagement {
|
|||||||
Write-Host "Cleanup complete."
|
Write-Host "Cleanup complete."
|
||||||
|
|
||||||
Write-Host "Unmounting image..."
|
Write-Host "Unmounting image..."
|
||||||
Dismount-WindowsImage -Path $scratchDir -Save
|
Dismount-WindowsImage -Path "$scratchDir" -Save
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -403,7 +403,7 @@ public class PowerManagement {
|
|||||||
reg unload HKLM\zSYSTEM
|
reg unload HKLM\zSYSTEM
|
||||||
|
|
||||||
Write-Host "Unmounting image..."
|
Write-Host "Unmounting image..."
|
||||||
Dismount-WindowsImage -Path $scratchDir -Save
|
Dismount-WindowsImage -Path "$scratchDir" -Save
|
||||||
|
|
||||||
Write-Host "Creating ISO image"
|
Write-Host "Creating ISO image"
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ public class PowerManagement {
|
|||||||
|
|
||||||
Write-Host "[INFO] Using oscdimg.exe from: $oscdimgPath"
|
Write-Host "[INFO] Using oscdimg.exe from: $oscdimgPath"
|
||||||
|
|
||||||
$oscdimgProc = Start-Process -FilePath "$oscdimgPath" -ArgumentList "-m -o -u2 -udfver102 -bootdata:2#p0,e,b$mountDir\boot\etfsboot.com#pEF,e,b$mountDir\efi\microsoft\boot\efisys.bin `"$mountDir`" `"$($SaveDialog.FileName)`"" -Wait -PassThru -NoNewWindow
|
$oscdimgProc = Start-Process -FilePath "$oscdimgPath" -ArgumentList "-m -o -u2 -udfver102 -bootdata:2#p0,e,b`"$mountDir\boot\etfsboot.com`"#pEF,e,b`"$mountDir\efi\microsoft\boot\efisys.bin`" `"$mountDir`" `"$($SaveDialog.FileName)`"" -Wait -PassThru -NoNewWindow
|
||||||
|
|
||||||
$LASTEXITCODE = $oscdimgProc.ExitCode
|
$LASTEXITCODE = $oscdimgProc.ExitCode
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user