Merge branch 'test-2024-02-07-refactor-noapps' into test-2024-02-07-refactor-noapps

This commit is contained in:
Chris Titus 2024-03-21 16:04:35 -07:00 committed by GitHub
commit 952c6b704a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 2310 additions and 1052 deletions

View File

@ -24,15 +24,14 @@ Get-ChildItem .\functions -Recurse -File | ForEach-Object {
Get-Content $psitem.FullName | Out-File ./$scriptname -Append -Encoding ascii
}
$xaml = (Get-Content .\xaml\inputXML.xaml).replace("'","''")
Write-output "`$inputXML = '$xaml'" | Out-File ./$scriptname -Append -Encoding ascii
Get-ChildItem .\config | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object {
$json = (Get-Content $psitem.FullName).replace("'","''")
$sync.configs.$($psitem.BaseName) = $json | convertfrom-json
Write-output "`$sync.configs.$($psitem.BaseName) = '$json' `| convertfrom-json" | Out-File ./$scriptname -Append -Encoding ascii
}
$xaml = (Get-Content .\xaml\inputXML.xaml).replace("'","''")
# Dot-source the Get-TabXaml function
. .\functions\private\Get-TabXaml.ps1
@ -44,4 +43,21 @@ $tabColumns | Out-File -FilePath ".\xaml\inputTweaks.xaml" -Encoding ascii
$tabColumns = Get-TabXaml "feature"
$tabColumns | Out-File -FilePath ".\xaml\inputFeatures.xaml" -Encoding ascii
# Assuming inputApp.xaml is in the same directory as main.ps1
$appXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputApp.xaml"
$tweaksXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputTweaks.xaml"
$featuresXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputFeatures.xaml"
# Load the XAML content from inputApp.xaml
$appXamlContent = Get-Content -Path $appXamlPath -Raw
$tweaksXamlContent = Get-Content -Path $tweaksXamlPath -Raw
$featuresXamlContent = Get-Content -Path $featuresXamlPath -Raw
# Replace the placeholder in $inputXML with the content of inputApp.xaml
$xaml = $xaml -replace "{{InstallPanel_applications}}", $appXamlContent
$xaml = $xaml -replace "{{InstallPanel_tweaks}}", $tweaksXamlContent
$xaml = $xaml -replace "{{InstallPanel_features}}", $featuresXamlContent
Write-output "`$inputXML = '$xaml'" | Out-File ./$scriptname -Append -Encoding ascii
Get-Content .\scripts\main.ps1 | Out-File ./$scriptname -Append -Encoding ascii

View File

@ -387,7 +387,7 @@
"category": "Microsoft Tools",
"choco": "dotnet-8.0-runtime",
"content": ".NET Desktop Runtime 8",
"description": ".NET Desktop Runtime 8 is a runtime environment required for running applications developed with .NET 7.",
"description": ".NET Desktop Runtime 8 is a runtime environment required for running applications developed with .NET 8.",
"link": "https://dotnet.microsoft.com/download/dotnet/8.0",
"winget": "Microsoft.DotNet.DesktopRuntime.8"
},

View File

@ -1,5 +1,5 @@
{
"Classic": {
"Classic": {
"ComboBoxBackgroundColor": "#FFFFFF",
"LabelboxForegroundColor": "#000000",
"MainForegroundColor": "#000000",
@ -60,5 +60,35 @@
"BorderColor": "#FFAC1C",
"BorderOpacity": "0.8",
"ShadowPulse": "0:0:3"
},
"Dark": {
"ComboBoxBackgroundColor": "#000000",
"LabelboxForegroundColor": "#FFEE58",
"MainForegroundColor": "#9CCC65",
"MainBackgroundColor": "#000000",
"LabelBackgroundColor": "#000000",
"LinkForegroundColor": "#add8e6",
"LinkHoverForegroundColor": "#FFFFFF",
"ComboBoxForegroundColor": "#FFEE58",
"ButtonInstallBackgroundColor": "#222222",
"ButtonTweaksBackgroundColor": "#333333",
"ButtonConfigBackgroundColor": "#444444",
"ButtonUpdatesBackgroundColor": "#555555",
"ButtonInstallForegroundColor": "#FFFFFF",
"ButtonTweaksForegroundColor": "#FFFFFF",
"ButtonConfigForegroundColor": "#FFFFFF",
"ButtonUpdatesForegroundColor": "#FFFFFF",
"ButtonBackgroundColor": "#000019",
"ButtonBackgroundPressedColor": "#9CCC65",
"ButtonBackgroundMouseoverColor": "#FF5733",
"ButtonBackgroundSelectedColor": "#FF5733",
"ButtonForegroundColor": "#9CCC65",
"ButtonBorderThickness": "1",
"ButtonMargin": "1",
"ButtonCornerRadius": "2",
"ToggleButtonHeight": "25",
"BorderColor": "#FFAC1C",
"BorderOpacity": "0.2",
"ShadowPulse": "Forever"
}
}
}

View File

@ -2306,6 +2306,7 @@
Write-Host \"Removing OneDrive leftovers\"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\Microsoft\\OneDrive\"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\OneDrive\"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:programdata\\Microsoft OneDrive\"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:systemdrive\\OneDriveTemp\"
# check if directory is empty before removing:

View File

@ -33,12 +33,12 @@ Function Install-WinUtilProgramWinget {
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --scope=machine --silent $Program" -NoNewWindow -Wait
}
if($manage -eq "Uninstalling"){
Start-Process -FilePath winget -ArgumentList "uninstall -e --purge --force --silent $Program" -NoNewWindow -Wait
}
Start-Process -FilePath winget -ArgumentList "uninstall -e --accept-source-agreements --purge --force --silent $Program" -NoNewWindow -Wait
}
$X++
}
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
}
}

View File

@ -18,28 +18,23 @@ function Test-CompatibleImage() {
<#
.SYNOPSIS
Checks the version of a Windows image and determines whether or not it is compatible depending on the Major property
Checks the version of a Windows image and determines whether or not it is compatible with a specific feature depending on a desired version
.PARAMETER imgVersion
The version of the Windows image
.PARAMETER Name
imgVersion - The version of the Windows image
desiredVersion - The version to compare the image version with
#>
param
(
[Parameter(Mandatory = $true)] [string] $imgVersion
[Parameter(Mandatory = $true, Position=0)] [string] $imgVersion,
[Parameter(Mandatory = $true, Position=1)] [Version] $desiredVersion
)
try {
$version = [Version]$imgVersion
if ($version.Major -ge 10)
{
return $True
}
else
{
return $False
}
return $version -ge $desiredVersion
} catch {
return $False
}
@ -247,7 +242,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
foreach($itemToDelete in $itemsToDelete)
{
$status = "Deleteing $($itemToDelete)"
$status = "Deleting $($itemToDelete)"
Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100)
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
@ -321,7 +316,7 @@ function New-Unattend {
<unattend xmlns="urn:schemas-microsoft-com:unattend"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<#REPLACEME#>
<settings pass="auditUser">
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
@ -362,6 +357,26 @@ function New-Unattend {
</settings>
</unattend>
'@
$specPass = @'
<settings pass="specialize">
<component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CEIPEnabled>0</CEIPEnabled>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>
</component>
</settings>
'@
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false)
{
# Replace the placeholder text with an empty string to make it valid for Windows 10 Setup
$unattend = $unattend.Replace("<#REPLACEME#>", "").Trim()
}
else
{
# Replace the placeholder text with the Specialize pass
$unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim()
}
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force
}
@ -622,6 +637,13 @@ function New-FirstRun {
$shortcut.Arguments = "-NoProfile -ExecutionPolicy Bypass -Command `"$command`""
# Save the shortcut
$shortcut.Save()
# Make the shortcut have 'Run as administrator' property on
$bytes = [System.IO.File]::ReadAllBytes($shortcutPath)
# Set byte value at position 0x15 in hex, or 21 in decimal, from the value 0x00 to 0x20 in hex
$bytes[0x15] = $bytes[0x15] -bor 0x20
[System.IO.File]::WriteAllBytes($shortcutPath, $bytes)
Write-Host "Shortcut created at: $shortcutPath"
#
# Done create WinUtil shortcut on the desktop
@ -631,4 +653,4 @@ function New-FirstRun {
'@
$firstRun | Out-File -FilePath "$env:temp\FirstStartup.ps1" -Force
}
}

View File

@ -0,0 +1,29 @@
function Invoke-GPUCheck {
$gpuInfo = Get-WmiObject Win32_VideoController
foreach ($gpu in $gpuInfo) {
$gpuName = $gpu.Name
if ($gpuName -like "*NVIDIA*") {
return $true # NVIDIA GPU found
}
}
foreach ($gpu in $gpuInfo) {
$gpuName = $gpu.Name
if ($gpuName -like "*AMD Radeon RX*") {
return $true # AMD GPU Found
}
}
foreach ($gpu in $gpuInfo) {
$gpuName = $gpu.Name
if ($gpuName -like "*UHD*") {
return $false # Intel Intergrated GPU Found
}
}
foreach ($gpu in $gpuInfo) {
$gpuName = $gpu.Name
if ($gpuName -like "*AMD Radeon(TM)*") {
return $false # AMD Intergrated GPU Found
}
}
}

View File

@ -20,11 +20,17 @@ function Test-WinUtilPackageManager {
# Install Winget if not detected
$wingetExists = Get-Command -Name winget -ErrorAction SilentlyContinue
if ($wingetExists) {
$wingetVersion = [System.Version]::Parse((winget --version).Trim('v'))
$wingetversionfull = (winget --version)
$wingetversiontrim = $wingetversionfull.Trim('v')
if ($wingetversiontrim.EndsWith("-preview")) {
$wingetversiontrim = $wingetversiontrim.Trim('-preview')
$wingetpreview = $true
}
$wingetVersion = [System.Version]::Parse($wingetversiontrim)
$minimumWingetVersion = [System.Version]::new(1,2,10691) # Win 11 23H2 comes with bad winget v1.2.10691
$wingetOutdated = $wingetVersion -le $minimumWingetVersion
Write-Host "Winget v$wingetVersion"
Write-Host "Winget $wingetVersionfull"
}
if (!$wingetExists -or $wingetOutdated) {
@ -37,17 +43,21 @@ function Test-WinUtilPackageManager {
if ($winget) {
if ($wingetExists -and !$wingetOutdated) {
Write-Host "- Winget up-to-date"
if (!$wingetpreview) {
Write-Host "- Winget up-to-date"
} else {
Write-Host "- Winget preview version detected. Unexptected problems may occur" -ForegroundColor Yellow
}
return $true
}
}
if($choco){
if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)){
if ($choco) {
if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) {
Write-Host "Chocolatey v$chocoVersion"
return $true
}
}
return $false
}
}

View File

@ -160,13 +160,18 @@ function Invoke-WPFGetIso {
$wimFile = "$mountDir\sources\install.wim"
Write-Host "Getting image information $wimFile"
if (-not (Test-Path -Path $wimFile -PathType Leaf))
if ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (-not (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -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/"
$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
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
throw
}
elseif ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf))
{
Write-Host "Install.esd found on the image. It needs to be converted to a WIM file in order to begin processing"
$wimFile = $wimFile.Replace(".wim", ".esd").Trim()
}
$sync.MicrowinWindowsFlavors.Items.Clear()
Get-WindowsImage -ImagePath $wimFile | ForEach-Object {
$imageIdx = $_.ImageIndex

View File

@ -2,12 +2,12 @@ function Invoke-WPFInstall {
<#
.SYNOPSIS
Installs the selected programs using winget
Installs the selected programs using winget, if one or more of the selected programs are already installed on the system, winget will try and perform an upgrade if there's a newer version to install.
#>
if($sync.ProcessRunning){
$msg = "[Invoke-WPFInstall] Install process is currently running."
$msg = "[Invoke-WPFInstall] An Install process is currently running."
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return
}
@ -15,7 +15,7 @@ function Invoke-WPFInstall {
$WingetInstall = (Get-WinUtilCheckBoxes)["Install"]
if ($wingetinstall.Count -eq 0) {
$WarningMsg = "Please select the program(s) to install"
$WarningMsg = "Please select the program(s) to install or upgrade"
[System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return
}
@ -41,4 +41,4 @@ function Invoke-WPFInstall {
Start-Sleep -Seconds 5
$sync.ProcessRunning = $False
}
}
}

View File

@ -57,10 +57,30 @@ public class PowerManagement {
$mountDir = $sync.MicrowinMountDir.Text
$scratchDir = $sync.MicrowinScratchDir.Text
# 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))
{
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"
if ($?)
{
Remove-Item -Path $mountDir\sources\install.esd -Force
# Since we've already exported the image index we wanted, switch to the first one
$index = 1
}
else
{
$msg = "The export process has failed and MicroWin processing cannot continue"
Write-Host "Failed to export the image"
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error)
return
}
}
$imgVersion = (Get-WindowsImage -ImagePath $mountDir\sources\install.wim -Index $index).Version
# Detect image version to avoid performing MicroWin processing on Windows 8 and earlier
if ((Test-CompatibleImage $imgVersion) -eq $false)
if ((Test-CompatibleImage $imgVersion $([System.Version]::new(10,0,10240,0))) -eq $false)
{
$msg = "This image is not compatible with MicroWin processing. Make sure it isn't a Windows 8 or earlier image."
$dlg_msg = $msg + "`n`nIf you want more information, the version of the image selected is $($imgVersion)`n`nIf an image has been incorrectly marked as incompatible, report an issue to the developers."

View File

@ -52,24 +52,13 @@ $sync.runspace.Open()
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
# Assuming inputApp.xaml is in the same directory as main.ps1
$appXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputApp.xaml"
$tweaksXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputTweaks.xaml"
$featuresXamlPath = Join-Path -Path $PSScriptRoot -ChildPath "xaml/inputFeatures.xaml"
# Load the XAML content from inputApp.xaml
$appXamlContent = Get-Content -Path $appXamlPath -Raw
$tweaksXamlContent = Get-Content -Path $tweaksXamlPath -Raw
$featuresXamlContent = Get-Content -Path $featuresXamlPath -Raw
# Replace the placeholder in $inputXML with the content of inputApp.xaml
$inputXML = $inputXML -replace "{{InstallPanel_applications}}", $appXamlContent
$inputXML = $inputXML -replace "{{InstallPanel_tweaks}}", $tweaksXamlContent
$inputXML = $inputXML -replace "{{InstallPanel_features}}", $featuresXamlContent
if ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True) {
$ctttheme = 'Matrix'
if (Invoke-GPUCheck -eq $True) {
$ctttheme = 'Matrix'
}
else {
$ctttheme = 'Dark'
}
}
else {
$ctttheme = 'Classic'
@ -463,4 +452,4 @@ Version : $($sync.version)
})
$sync["Form"].ShowDialog() | out-null
Stop-Transcript
Stop-Transcript

File diff suppressed because it is too large Load Diff

View File

@ -399,7 +399,7 @@
<CheckBox Name="WPFInstalldotnet7" Content=".NET Desktop Runtime 7" ToolTip=".NET Desktop Runtime 7 is a runtime environment required for running applications developed with .NET 7." Margin="0,0,2,0"/><TextBlock Name="WPFInstalldotnet7Link" Style="{StaticResource HoverTextBlockStyle}" Text="(?)" ToolTip="https://dotnet.microsoft.com/download/dotnet/7.0" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<CheckBox Name="WPFInstalldotnet8" Content=".NET Desktop Runtime 8" ToolTip=".NET Desktop Runtime 8 is a runtime environment required for running applications developed with .NET 7." Margin="0,0,2,0"/><TextBlock Name="WPFInstalldotnet8Link" Style="{StaticResource HoverTextBlockStyle}" Text="(?)" ToolTip="https://dotnet.microsoft.com/download/dotnet/8.0" />
<CheckBox Name="WPFInstalldotnet8" Content=".NET Desktop Runtime 8" ToolTip=".NET Desktop Runtime 8 is a runtime environment required for running applications developed with .NET 8." Margin="0,0,2,0"/><TextBlock Name="WPFInstalldotnet8Link" Style="{StaticResource HoverTextBlockStyle}" Text="(?)" ToolTip="https://dotnet.microsoft.com/download/dotnet/8.0" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<CheckBox Name="WPFInstallnuget" Content="NuGet" ToolTip="NuGet is a package manager for the .NET framework, enabling developers to manage and share libraries in their .NET applications." Margin="0,0,2,0"/><TextBlock Name="WPFInstallnugetLink" Style="{StaticResource HoverTextBlockStyle}" Text="(?)" ToolTip="https://www.nuget.org/" />

View File

@ -690,7 +690,7 @@
<RowDefinition Height="0.95*"/>
</Grid.RowDefinitions>
<StackPanel Background="{MainBackgroundColor}" Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Grid.ColumnSpan="3" Margin="5">
<Button Name="WPFinstall" Content=" Install Selected" Margin="2" />
<Button Name="WPFinstall" Content=" Install/Upgrade Selected" Margin="2" />
<Button Name="WPFInstallUpgrade" Content=" Upgrade All" Margin="2"/>
<Button Name="WPFuninstall" Content=" Uninstall Selection" Margin="2"/>
<Button Name="WPFGetInstalled" Content=" Get Installed" Margin="2"/>