mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
bf271b89e9
* File Converter * Adding wiki directory where we can start storing all the wikis for now (#1405) * change logseq url and add .net 8 (#1385) * Update applications.json Add Official logseq url Add .net runtime 8.0 * compile with new logseq and .net 8 runtime * add thorium avx2 * Compile Winutil * Anoter one of those huge PRs - Fix version inefficiency the version is already stored in sync, no need to slow down loading by one extra replace. - Created custom dialog and About message - Create a menu with Import/Export values - press on teh Settings cog in the right upper corner and save all the checkboxes - then you can either load them or load and run automatically - Made Import Export load accross the whole app - Optimized the way checkbox controls are looked up, it is 20% faster now - Added a switch to load all the boxes from a config file - example: .winutil.ps1 -Config "C:UsersasdfDesktop\111.json" - Added a switch to run all the action in unattended mode by passing -Run siwthc - example: .winutil.ps1 -Config "C:UsersasdfDesktop\111.json" -Run - This will run all the tweaks and install all the apps * Fixing a couple of bugs and blur fonts, also menu now closes when focus is lost * Remove Cider Music Player (#1400) * Update winutil.ps1 * Update applications.json * Compile Winutil * Checking in wiki files. Once you get wiki going you will be able to just copy this content to the wiki. Or leave it as-is, which maybe better because than the community could edit it * Adding microwin usage error wiki * fixing link the the new wiki location * Adding automation section to the readme * Fixing doc errors * Adding conda and a couple or tools used by scientists, also fixing a nesty bug with winget if you don't specify scope=machine tools like python will not work correctly * fix application mismatch * Update applications.json --------- Co-authored-by: Cristian Negulescu <cristian@clamsen.com> Co-authored-by: Chris Titus <dfm.titus@gmail.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Co-authored-by: KonTy <KonTy@github.com> Co-authored-by: Tommi Pöntinen <98650216+hamburgerghini1@users.noreply.github.com> Co-authored-by: Chris Titus <contact@christitus.com> * Compile Winutil * remove files application (#1408) * Update README.md (#1421) * Compile Winutil * Update links, descriptions + add choco id for twinkle tray (#1426) * update twinkle tray * update wingetui * update wisetoys link * update floorp link * Compile Winutil * Add some useful programs and fix an app's url (#1427) * fix the link for strawberry music player The existing one opens a python library * feat: add some useful apps * changed the link in the wrong place * Compile Winutil * Added new toggle tweak button (#1434) * add new ToggleSwitch * add new function to disable/enable toggle button * add new name of the button for the given toggle * added new toggle tweak * Compile Winutil * Feat: Add Microsoft Power BI program (#1438) * Compile Winutil * Fix Fredium App Link (#1440) * Update applications.json (#1448) Updated the link to Prism Launcher to point to the correct url * Compile Winutil * fix for bug with selecting presets and toggle switches (#1447) * Update Invoke-WPFPresets.ps1 * Update Invoke-WPFPresets.ps1 * Compile Winutil * Update winutil.ps1 --------- Co-authored-by: KonTy <9524513+KonTy@users.noreply.github.com> Co-authored-by: Cristian Negulescu <cristian@clamsen.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Co-authored-by: KonTy <KonTy@github.com> Co-authored-by: Tommi Pöntinen <98650216+hamburgerghini1@users.noreply.github.com> Co-authored-by: Munkk <152475628+munkk01@users.noreply.github.com> Co-authored-by: DeveloperDurp <developerdurp@durp.info> Co-authored-by: OmriOn <76548146+OmriOn@users.noreply.github.com> Co-authored-by: Keshav S <55992029+Keshav13142@users.noreply.github.com> Co-authored-by: Vuk Lekić <vuklekic22@gmail.com> Co-authored-by: André Gonzalez <lopescg@gmail.com> Co-authored-by: playgroundsskiff <149293245+playgroundsskiff@users.noreply.github.com> Co-authored-by: BusterBean <73446417+BusterBean@users.noreply.github.com>
161 lines
7.8 KiB
PowerShell
161 lines
7.8 KiB
PowerShell
function Invoke-WPFGetIso {
|
|
<#
|
|
.DESCRIPTION
|
|
Function to get the path to Iso file for MicroWin, unpack that isom=, read basic information and populate the UI Options
|
|
#>
|
|
|
|
Write-Host "Invoking WPFGetIso"
|
|
|
|
if($sync.ProcessRunning){
|
|
$msg = "GetIso process is currently running."
|
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
return
|
|
}
|
|
|
|
Write-Host " _ __ __ _ "
|
|
Write-Host " /\/\ (_) ___ _ __ ___ / / /\ \ \(_) _ __ "
|
|
Write-Host " / \ | | / __|| '__| / _ \ \ \/ \/ /| || '_ \ "
|
|
Write-Host "/ /\/\ \| || (__ | | | (_) | \ /\ / | || | | | "
|
|
Write-Host "\/ \/|_| \___||_| \___/ \/ \/ |_||_| |_| "
|
|
|
|
$oscdimgPath = Join-Path $env:TEMP 'oscdimg.exe'
|
|
$oscdImgFound = [bool] (Get-Command -ErrorAction Ignore -Type Application oscdimg.exe) -or (Test-Path $oscdimgPath -PathType Leaf)
|
|
Write-Host "oscdimg.exe on system: $oscdImgFound"
|
|
|
|
if (!$oscdImgFound)
|
|
{
|
|
$downloadFromGitHub = $sync.WPFMicrowinDownloadFromGitHub.IsChecked
|
|
|
|
if (!$downloadFromGitHub)
|
|
{
|
|
# only show the message to people who did check the box to download from github, if you check the box
|
|
# you consent to downloading it, no need to show extra dialogs
|
|
[System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it using choco. This might take a long time.")
|
|
# the step below needs choco to download oscdimg
|
|
$chocoFound = [bool] (Get-Command -ErrorAction Ignore -Type Application choco)
|
|
Write-Host "choco on system: $chocoFound"
|
|
if (!$chocoFound)
|
|
{
|
|
[System.Windows.MessageBox]::Show("choco.exe is not found on the system, you need choco to download oscdimg.exe")
|
|
return
|
|
}
|
|
|
|
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install windows-adk-oscdimg"
|
|
[System.Windows.MessageBox]::Show("oscdimg is installed, now close, reopen PowerShell terminal and re-launch winutil.ps1")
|
|
return
|
|
}
|
|
else {
|
|
[System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it from github. This might take a long time.")
|
|
Get-Oscdimg -oscdimgPath $oscdimgPath
|
|
$oscdImgFound = Test-Path $oscdimgPath -PathType Leaf
|
|
if (!$oscdImgFound) {
|
|
$msg = "oscdimg was not downloaded can not proceed"
|
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
|
return
|
|
}
|
|
else {
|
|
Write-Host "oscdimg.exe was successfully downloaded from github"
|
|
}
|
|
}
|
|
}
|
|
|
|
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
|
|
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
|
|
$openFileDialog.initialDirectory = $initialDirectory
|
|
$openFileDialog.filter = "ISO files (*.iso)| *.iso"
|
|
$openFileDialog.ShowDialog() | Out-Null
|
|
$filePath = $openFileDialog.FileName
|
|
|
|
if ([string]::IsNullOrEmpty($filePath))
|
|
{
|
|
Write-Host "No ISO is chosen"
|
|
return
|
|
}
|
|
|
|
Write-Host "File path $($filePath)"
|
|
if (-not (Test-Path -Path $filePath -PathType Leaf))
|
|
{
|
|
$msg = "File you've chosen doesn't exist"
|
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
|
return
|
|
}
|
|
|
|
try {
|
|
Write-Host "Mounting Iso. Please wait."
|
|
$mountedISO = Mount-DiskImage -PassThru "$filePath"
|
|
Write-Host "Done mounting Iso $mountedISO"
|
|
$driveLetter = (Get-Volume -DiskImage $mountedISO).DriveLetter
|
|
Write-Host "Iso mounted to '$driveLetter'"
|
|
} catch {
|
|
# @ChrisTitusTech please copy this wiki and change the link below to your copy of the wiki
|
|
Write-Error "Failed to mount the image. Error: $($_.Exception.Message)"
|
|
Write-Error "This is NOT winutil's problem, your ISO might be corrupt, or there is a problem on the system"
|
|
Write-Error "Please refer to this wiki for more details https://github.com/ChrisTitusTech/winutil/blob/main/wiki/Error-in-Winutil-MicroWin-during-ISO-mounting%2Cmd"
|
|
return
|
|
}
|
|
# storing off values in hidden fields for further steps
|
|
# there is probably a better way of doing this, I don't have time to figure this out
|
|
$sync.MicrowinIsoDrive.Text = $driveLetter
|
|
|
|
Write-Host "Setting up mount dir and scratch dirs"
|
|
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
|
|
$randomNumber = Get-Random -Minimum 1 -Maximum 9999
|
|
$randomMicrowin = "Microwin_${timestamp}_${randomNumber}"
|
|
$randomMicrowinScratch = "MicrowinScratch_${timestamp}_${randomNumber}"
|
|
$mountDir = Join-Path $env:TEMP $randomMicrowin
|
|
$scratchDir = Join-Path $env:TEMP $randomMicrowinScratch
|
|
$sync.MicrowinMountDir.Text = $mountDir
|
|
$sync.MicrowinScratchDir.Text = $scratchDir
|
|
Write-Host "Done setting up mount dir and scratch dirs"
|
|
Write-Host "Scratch dir is $scratchDir"
|
|
Write-Host "Image dir is $mountDir"
|
|
|
|
try {
|
|
|
|
#$data = @($driveLetter, $filePath)
|
|
New-Item -ItemType Directory -Force -Path "$($mountDir)" | Out-Null
|
|
New-Item -ItemType Directory -Force -Path "$($scratchDir)" | Out-Null
|
|
Write-Host "Copying Windows image. This will take awhile, please don't use UI or cancel this step!"
|
|
|
|
# xcopy we can verify files and also not copy files that already exist, but hard to measure
|
|
# xcopy.exe /E /I /H /R /Y /J $DriveLetter":" $mountDir >$null
|
|
$totalTime = Measure-Command { Copy-Files "$($driveLetter):" $mountDir -Recurse -Force }
|
|
Write-Host "Copy complete! Total Time: $($totalTime.Minutes)m$($totalTime.Seconds)s"
|
|
|
|
$wimFile = "$mountDir\sources\install.wim"
|
|
Write-Host "Getting image information $wimFile"
|
|
|
|
if (-not (Test-Path -Path $wimFile -PathType Leaf))
|
|
{
|
|
$msg = "Install.wim file doesn't exist in the image, this could happen if you use unofficial Windows images, or a Media creation tool, which creates a final image that can not be modified. 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
|
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
|
|
throw
|
|
}
|
|
Get-WindowsImage -ImagePath $wimFile | ForEach-Object {
|
|
$imageIdx = $_.ImageIndex
|
|
$imageName = $_.ImageName
|
|
$sync.MicrowinWindowsFlavors.Items.Add("$imageIdx : $imageName")
|
|
}
|
|
$sync.MicrowinWindowsFlavors.SelectedIndex = 0
|
|
Get-Volume $driveLetter | Get-DiskImage | Dismount-DiskImage
|
|
Write-Host "Selected value '$($sync.MicrowinWindowsFlavors.SelectedValue)'....."
|
|
|
|
$sync.MicrowinOptionsPanel.Visibility = 'Visible'
|
|
} catch {
|
|
Write-Host "Dismounting bad image..."
|
|
Get-Volume $driveLetter | Get-DiskImage | Dismount-DiskImage
|
|
Remove-Item -Recurse -Force "$($scratchDir)"
|
|
Remove-Item -Recurse -Force "$($mountDir)"
|
|
}
|
|
|
|
Write-Host "Done reading and unpacking ISO"
|
|
Write-Host ""
|
|
Write-Host "*********************************"
|
|
Write-Host "Check the UI for further steps!!!"
|
|
|
|
$sync.ProcessRunning = $false
|
|
}
|
|
|
|
|