mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-27 16:31:30 -06:00
Compare commits
19 Commits
74ccfa34d4
...
bb9369bbcb
Author | SHA1 | Date | |
---|---|---|---|
|
bb9369bbcb | ||
|
171441ddcf | ||
|
7a0c40420e | ||
|
0f0d9d0ae3 | ||
|
6149738e6c | ||
|
aa0b03feda | ||
|
fc53ca802b | ||
|
e6c1394b5d | ||
|
fb21479531 | ||
|
411bc66d7e | ||
|
2b2b11e4f2 | ||
|
0e7a34c5e5 | ||
|
d535e7ebca | ||
|
15024434d9 | ||
|
46e457dde8 | ||
|
12446c5b83 | ||
|
ce5ebca87a | ||
|
cb21a39f62 | ||
|
b001842a61 |
2
.github/mkdocs.yml
vendored
2
.github/mkdocs.yml
vendored
@ -5,7 +5,7 @@ repo_url: https://github.com/ChrisTitusTech/winutil
|
||||
nav:
|
||||
- Introduction: 'index.md'
|
||||
- User Guide: 'userguide.md'
|
||||
- Contributing Guide: 'contribute.md'
|
||||
- Contributing Guide: 'CONTRIBUTING.md'
|
||||
- Documentation:
|
||||
- Dev Docs: 'devdocs.md'
|
||||
- Known Issues: 'KnownIssues.md'
|
||||
|
@ -306,13 +306,23 @@
|
||||
"ButtonWidth": "300",
|
||||
"link": "https://christitustech.github.io/winutil/dev/features/Legacy-Windows-Panels/user"
|
||||
},
|
||||
"WPFWinUtilPSProfile": {
|
||||
"WPFWinUtilInstallPSProfile": {
|
||||
"Content": "Install CTT PowerShell Profile",
|
||||
"category": "Powershell Profile",
|
||||
"panel": "2",
|
||||
"Order": "a083_",
|
||||
"Type": "Button",
|
||||
"ButtonWidth": "300"
|
||||
"ButtonWidth": "300",
|
||||
"link": "https://christitustech.github.io/winutil/dev/features/Powershell-Profile/PSProfileInstall"
|
||||
},
|
||||
"WPFWinUtilUninstallPSProfile": {
|
||||
"Content": "Uninstall CTT PowerShell Profile",
|
||||
"category": "Powershell Profile",
|
||||
"panel": "2",
|
||||
"Order": "a084_",
|
||||
"Type": "Button",
|
||||
"ButtonWidth": "300",
|
||||
"link": "https://christitustech.github.io/winutil/dev/features/Powershell-Profile/PSProfileUninstall"
|
||||
},
|
||||
"WPFWinUtilSSHServer": {
|
||||
"Content": "Enable OpenSSH Server",
|
||||
@ -322,4 +332,4 @@
|
||||
"Type": "Button",
|
||||
"ButtonWidth": "300"
|
||||
}
|
||||
}
|
||||
}
|
@ -2,12 +2,12 @@
|
||||
"shared":{
|
||||
"CustomDialogFontSize": "12",
|
||||
"CustomDialogFontSizeHeader": "14",
|
||||
"CustomDialogIconSize": "25",
|
||||
"CustomDialogLogoSize": "25",
|
||||
"CustomDialogWidth": "400",
|
||||
"CustomDialogHeight": "200",
|
||||
"FontSize": "12",
|
||||
"FontFamily": "Arial",
|
||||
"FontSizeHeading": "16",
|
||||
"HeadingFontSize": "16",
|
||||
"HeaderFontFamily": "Consolas, Monaco",
|
||||
"CheckBoxBulletDecoratorSize": "14",
|
||||
"CheckBoxMargin": "15,0,0,2",
|
||||
@ -27,7 +27,7 @@
|
||||
"ButtonFontFamily": "Arial",
|
||||
"ButtonWidth": "200",
|
||||
"ButtonHeight": "25",
|
||||
"ConfigTabButtonFontSize": "16",
|
||||
"ConfigUpdateButtonFontSize": "14",
|
||||
"SearchBarWidth": "200",
|
||||
"SearchBarHeight": "26",
|
||||
"SearchBarTextBoxFontSize": "12",
|
||||
@ -44,7 +44,7 @@
|
||||
"MainForegroundColor": "#232629",
|
||||
"MainBackgroundColor": "#F7F7F7",
|
||||
"LabelBackgroundColor": "#F7F7F7",
|
||||
"LinkForegroundColor": "#232629",
|
||||
"LinkForegroundColor": "#484848",
|
||||
"LinkHoverForegroundColor": "#232629",
|
||||
"ScrollBarBackgroundColor": "#4A4D52",
|
||||
"ScrollBarHoverColor": "#5A5D62",
|
||||
|
@ -11,21 +11,21 @@
|
||||
"Name": "EnableActivityFeed",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\System",
|
||||
"Name": "PublishUserActivities",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\System",
|
||||
"Name": "UploadUserActivities",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
}
|
||||
],
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/AH"
|
||||
@ -1598,126 +1598,126 @@
|
||||
"Name": "CreateDesktopShortcutDefault",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "PersonalizationReportingEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "ShowRecommendationsEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "HideFirstRunExperience",
|
||||
"Type": "DWord",
|
||||
"Value": "1",
|
||||
"OriginalValue": "0"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "UserFeedbackAllowed",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "ConfigureDoNotTrack",
|
||||
"Type": "DWord",
|
||||
"Value": "1",
|
||||
"OriginalValue": "0"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "AlternateErrorPagesEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "EdgeCollectionsEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "EdgeShoppingAssistantEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "MicrosoftEdgeInsiderPromotionEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "PersonalizationReportingEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "ShowMicrosoftRewards",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "WebWidgetAllowed",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "DiagnosticData",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "EdgeAssetDeliveryServiceEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "EdgeCollectionsEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "CryptoWalletEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Edge",
|
||||
"Name": "WalletDonationEnabled",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
}
|
||||
],
|
||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/EdgeDebloat"
|
||||
@ -1731,7 +1731,7 @@
|
||||
"registry": [
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent",
|
||||
"OriginalValue": "0",
|
||||
"OriginalValue": "<RemoveEntry>",
|
||||
"Name": "DisableWindowsConsumerFeatures",
|
||||
"Value": "1",
|
||||
"Type": "DWord"
|
||||
@ -1818,11 +1818,11 @@
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"Name": "AllowTelemetry",
|
||||
"OriginalValue": "1"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\DataCollection",
|
||||
"OriginalValue": "1",
|
||||
"OriginalValue": "<RemoveEntry>",
|
||||
"Name": "AllowTelemetry",
|
||||
"Value": "0",
|
||||
"Type": "DWord"
|
||||
@ -1906,21 +1906,21 @@
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\DataCollection",
|
||||
"OriginalValue": "0",
|
||||
"OriginalValue": "<RemoveEntry>",
|
||||
"Name": "DoNotShowFeedbackNotifications",
|
||||
"Value": "1",
|
||||
"Type": "DWord"
|
||||
},
|
||||
{
|
||||
"Path": "HKCU:\\SOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent",
|
||||
"OriginalValue": "0",
|
||||
"OriginalValue": "<RemoveEntry>",
|
||||
"Name": "DisableTailoredExperiencesWithDiagnosticData",
|
||||
"Value": "1",
|
||||
"Type": "DWord"
|
||||
},
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\AdvertisingInfo",
|
||||
"OriginalValue": "0",
|
||||
"OriginalValue": "<RemoveEntry>",
|
||||
"Name": "DisabledByGroupPolicy",
|
||||
"Value": "1",
|
||||
"Type": "DWord"
|
||||
@ -2047,7 +2047,7 @@
|
||||
},
|
||||
{
|
||||
"Path": "HKCU:\\SOFTWARE\\Policies\\Microsoft\\Windows\\Windows Feeds",
|
||||
"OriginalValue": "1",
|
||||
"OriginalValue": "<RemoveEntry>",
|
||||
"Name": "EnableFeeds",
|
||||
"Value": "0",
|
||||
"Type": "DWord"
|
||||
@ -2061,7 +2061,7 @@
|
||||
},
|
||||
{
|
||||
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
|
||||
"OriginalValue": "1",
|
||||
"OriginalValue": "<RemoveEntry>",
|
||||
"Name": "HideSCAMeetNow",
|
||||
"Value": "1",
|
||||
"Type": "DWord"
|
||||
@ -2553,14 +2553,14 @@
|
||||
"Name": "TurnOffWindowsCopilot",
|
||||
"Type": "DWord",
|
||||
"Value": "1",
|
||||
"OriginalValue": "0"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKCU:\\Software\\Policies\\Microsoft\\Windows\\WindowsCopilot",
|
||||
"Name": "TurnOffWindowsCopilot",
|
||||
"Type": "DWord",
|
||||
"Value": "1",
|
||||
"OriginalValue": "0"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
|
||||
@ -2597,7 +2597,7 @@
|
||||
"Name": "DisableAIDataAnalysis",
|
||||
"Type": "DWord",
|
||||
"Value": "1",
|
||||
"OriginalValue": "0"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
}
|
||||
],
|
||||
"InvokeScript": [
|
||||
@ -2824,7 +2824,7 @@
|
||||
"Name": "DisableNotificationCenter",
|
||||
"Type": "DWord",
|
||||
"Value": "1",
|
||||
"OriginalValue": "0"
|
||||
"OriginalValue": "<RemoveEntry>"
|
||||
},
|
||||
{
|
||||
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\PushNotifications",
|
||||
@ -3183,7 +3183,7 @@
|
||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\GameDVR",
|
||||
"Name": "AllowGameDVR",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1",
|
||||
"OriginalValue": "<RemoveEntry>",
|
||||
"Type": "DWord"
|
||||
}
|
||||
],
|
||||
|
38
docs/dev/features/PowerShell-Profile/PSProfileInstall.md
Normal file
38
docs/dev/features/PowerShell-Profile/PSProfileInstall.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Install CTT PowerShell Profile
|
||||
|
||||
Last Updated: 2024-10-01
|
||||
|
||||
|
||||
!!! info
|
||||
The Development Documentation is auto generated for every compilation of WinUtil, meaning a part of it will always stay up-to-date. **Developers do have the ability to add custom content, which won't be updated automatically.**
|
||||
|
||||
|
||||
<!-- BEGIN CUSTOM CONTENT -->
|
||||
|
||||
<!-- END CUSTOM CONTENT -->
|
||||
|
||||
<details>
|
||||
<summary>Preview Code</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"Content": "Install CTT PowerShell Profile",
|
||||
"category": "Powershell Profile",
|
||||
"panel": "2",
|
||||
"Order": "a083_",
|
||||
"Type": "Button",
|
||||
"ButtonWidth": "300",
|
||||
"link": "https://christitustech.github.io/winutil/dev/features/Powershell-Profile/PSProfileInstall"
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
<!-- BEGIN SECOND CUSTOM CONTENT -->
|
||||
|
||||
<!-- END SECOND CUSTOM CONTENT -->
|
||||
|
||||
|
||||
[View the JSON file](https://github.com/ChrisTitusTech/winutil/tree/main/config/feature.json)
|
||||
|
38
docs/dev/features/PowerShell-Profile/PSProfileUninstall.md
Normal file
38
docs/dev/features/PowerShell-Profile/PSProfileUninstall.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Uninstall CTT PowerShell Profile
|
||||
|
||||
Last Updated: 2024-10-01
|
||||
|
||||
|
||||
!!! info
|
||||
The Development Documentation is auto generated for every compilation of WinUtil, meaning a part of it will always stay up-to-date. **Developers do have the ability to add custom content, which won't be updated automatically.**
|
||||
|
||||
|
||||
<!-- BEGIN CUSTOM CONTENT -->
|
||||
|
||||
<!-- END CUSTOM CONTENT -->
|
||||
|
||||
<details>
|
||||
<summary>Preview Code</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"Content": "Uninstall CTT PowerShell Profile",
|
||||
"category": "Powershell Profile",
|
||||
"panel": "2",
|
||||
"Order": "a084_",
|
||||
"Type": "Button",
|
||||
"ButtonWidth": "300",
|
||||
"link": "https://christitustech.github.io/winutil/dev/features/Powershell-Profile/PSProfileUninstall"
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
<!-- BEGIN SECOND CUSTOM CONTENT -->
|
||||
|
||||
<!-- END SECOND CUSTOM CONTENT -->
|
||||
|
||||
|
||||
[View the JSON file](https://github.com/ChrisTitusTech/winutil/tree/main/config/feature.json)
|
||||
|
103
functions/private/Invoke-WinUtilInstallPSProfile.ps1
Normal file
103
functions/private/Invoke-WinUtilInstallPSProfile.ps1
Normal file
@ -0,0 +1,103 @@
|
||||
function Invoke-WinUtilInstallPSProfile {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Backs up your original profile then installs and applies the CTT PowerShell profile.
|
||||
#>
|
||||
|
||||
Invoke-WPFRunspace -ArgumentList $PROFILE -DebugPreference $DebugPreference -ScriptBlock {
|
||||
# Remap the automatic built-in $PROFILE variable to the parameter named $PSProfile.
|
||||
param ($PSProfile)
|
||||
|
||||
function Invoke-PSSetup {
|
||||
# Define the URL used to download Chris Titus Tech's PowerShell profile.
|
||||
$url = "https://raw.githubusercontent.com/ChrisTitusTech/powershell-profile/main/Microsoft.PowerShell_profile.ps1"
|
||||
|
||||
# Get the file hash for the user's current PowerShell profile.
|
||||
$OldHash = Get-FileHash $PSProfile -ErrorAction SilentlyContinue
|
||||
|
||||
# Download Chris Titus Tech's PowerShell profile to the 'TEMP' folder.
|
||||
Invoke-RestMethod $url -OutFile "$env:TEMP/Microsoft.PowerShell_profile.ps1"
|
||||
|
||||
# Get the file hash for Chris Titus Tech's PowerShell profile.
|
||||
$NewHash = Get-FileHash "$env:TEMP/Microsoft.PowerShell_profile.ps1"
|
||||
|
||||
# Store the file hash of Chris Titus Tech's PowerShell profile.
|
||||
if (!(Test-Path "$PSProfile.hash")) {
|
||||
$NewHash.Hash | Out-File "$PSProfile.hash"
|
||||
}
|
||||
|
||||
# Check if the new profile's hash doesn't match the old profile's hash.
|
||||
if ($NewHash.Hash -ne $OldHash.Hash) {
|
||||
# Check if oldprofile.ps1 exists and use it as a profile backup source.
|
||||
if (Test-Path "$env:USERPROFILE\oldprofile.ps1") {
|
||||
Write-Host "===> Backup File Exists... <===" -ForegroundColor Yellow
|
||||
Write-Host "===> Moving Backup File... <===" -ForegroundColor Yellow
|
||||
Copy-Item "$env:USERPROFILE\oldprofile.ps1" "$PSProfile.bak"
|
||||
Write-Host "===> Profile Backup: Done. <===" -ForegroundColor Yellow
|
||||
} else {
|
||||
# If oldprofile.ps1 does not exist use $PSProfile as a profile backup source.
|
||||
# Check if the profile backup file has not already been created on the disk.
|
||||
if ((Test-Path $PSProfile) -and (-not (Test-Path "$PSProfile.bak"))) {
|
||||
# Let the user know their PowerShell profile is being backed up.
|
||||
Write-Host "===> Backing Up Profile... <===" -ForegroundColor Yellow
|
||||
|
||||
# Copy the user's current PowerShell profile to the backup file path.
|
||||
Copy-Item -Path $PSProfile -Destination "$PSProfile.bak"
|
||||
|
||||
# Let the user know the profile backup has been completed successfully.
|
||||
Write-Host "===> Profile Backup: Done. <===" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
# Let the user know Chris Titus Tech's PowerShell profile is being installed.
|
||||
Write-Host "===> Installing Profile... <===" -ForegroundColor Yellow
|
||||
|
||||
# Start a new hidden PowerShell instance because setup.ps1 does not work in runspaces.
|
||||
Start-Process -FilePath "pwsh" -ArgumentList "-ExecutionPolicy Bypass -NoProfile -Command `"Invoke-Expression (Invoke-WebRequest `'https://github.com/ChrisTitusTech/powershell-profile/raw/main/setup.ps1`')`"" -WindowStyle Hidden -Wait
|
||||
|
||||
# Let the user know Chris Titus Tech's PowerShell profile has been installed successfully.
|
||||
Write-Host "Profile has been installed. Please restart your shell to reflect the changes!" -ForegroundColor Magenta
|
||||
|
||||
# Let the user know Chris Titus Tech's PowerShell profile has been setup successfully.
|
||||
Write-Host "===> Finished Profile Setup <===" -ForegroundColor Yellow
|
||||
} else {
|
||||
# Let the user know Chris Titus Tech's PowerShell profile is already fully up-to-date.
|
||||
Write-Host "Profile is up to date" -ForegroundColor Magenta
|
||||
}
|
||||
}
|
||||
|
||||
# Check if PowerShell Core is currently installed as a program and is available as a command.
|
||||
if (Get-Command "pwsh" -ErrorAction SilentlyContinue) {
|
||||
# Check if the version of PowerShell Core currently in use is version 7 or higher.
|
||||
if ($PSVersionTable.PSVersion.Major -ge 7) {
|
||||
# Invoke the PowerShell Profile setup script to install Chris Titus Tech's PowerShell Profile.
|
||||
Invoke-PSSetup
|
||||
} else {
|
||||
# Let the user know that PowerShell 7 is installed but is not currently in use.
|
||||
Write-Host "This profile requires Powershell 7, which is currently installed but not used!" -ForegroundColor Red
|
||||
|
||||
# Load the necessary .NET library required to use Windows Forms to show dialog boxes.
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
|
||||
# Display the message box asking if the user wants to install PowerShell 7 or not.
|
||||
$question = [System.Windows.Forms.MessageBox]::Show(
|
||||
"Profile requires Powershell 7, which is currently installed but not used! Do you want to install the profile for Powershell 7?",
|
||||
"Question",
|
||||
[System.Windows.Forms.MessageBoxButtons]::YesNo,
|
||||
[System.Windows.Forms.MessageBoxIcon]::Question
|
||||
)
|
||||
|
||||
# Proceed with the installation and setup of the profile as the user pressed the 'Yes' button.
|
||||
if ($question -eq [System.Windows.Forms.DialogResult]::Yes) {
|
||||
Invoke-PSSetup
|
||||
} else {
|
||||
# Let the user know the setup of the profile will not proceed as they pressed the 'No' button.
|
||||
Write-Host "Not proceeding with the profile setup!" -ForegroundColor Magenta
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Let the user know that the profile requires PowerShell Core but it is not currently installed.
|
||||
Write-Host "This profile requires Powershell Core, which is currently not installed!" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
}
|
187
functions/private/Invoke-WinUtilUninstallPSProfile.ps1
Normal file
187
functions/private/Invoke-WinUtilUninstallPSProfile.ps1
Normal file
@ -0,0 +1,187 @@
|
||||
function Invoke-WinUtilUninstallPSProfile {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
# Uninstalls the CTT PowerShell profile then restores the original profile.
|
||||
#>
|
||||
|
||||
Invoke-WPFRunspace -ArgumentList $PROFILE -DebugPreference $DebugPreference -ScriptBlock {
|
||||
# Remap the automatic built-in $PROFILE variable to the parameter named $PSProfile.
|
||||
param ($PSProfile)
|
||||
|
||||
# Helper function used to uninstall a specific Nerd Fonts font package.
|
||||
function Uninstall-NerdFonts {
|
||||
# Define the parameters block for the Uninstall-NerdFonts function.
|
||||
param (
|
||||
[string]$FontsPath = "$env:LOCALAPPDATA\Microsoft\Windows\Fonts",
|
||||
[string]$FontFamilyName = "CaskaydiaCoveNerdFont"
|
||||
)
|
||||
|
||||
# Get the list of installed fonts as specified by the FontFamilyName parameter.
|
||||
$Fonts = Get-ChildItem $FontsPath -Recurse -Filter "*.ttf" | Where-Object { $_.Name -match $FontFamilyName }
|
||||
|
||||
# Check if the specified fonts are currently installed on the system.
|
||||
if ($Fonts) {
|
||||
# Let the user know that the Nerd Fonts are currently being uninstalled.
|
||||
Write-Host "===> Uninstalling: Nerd Fonts... <===" -ForegroundColor Yellow
|
||||
|
||||
# Loop over the font files and remove each installed font file one-by-one.
|
||||
$Fonts | ForEach-Object {
|
||||
# Check if the font file exists on the disk before attempting to remove it.
|
||||
if (Test-Path "$($_.FullName)") {
|
||||
# Remove the found font files from the disk; uninstalling the font.
|
||||
Remove-Item "$($_.FullName)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Let the user know that the Nerd Fonts package has been uninstalled from the system.
|
||||
if (-not $Fonts) {
|
||||
Write-Host "===> Successfully Uninstalled: Nerd Fonts. <===" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
# Check if Chris Titus Tech's PowerShell profile is currently available in the PowerShell profile folder.
|
||||
if (Test-Path $PSProfile -PathType Leaf) {
|
||||
# Set the GitHub repo path used for looking up the name of Chris Titus Tech's powershell-profile repo.
|
||||
$GitHubRepoPath = "ChrisTitusTech/powershell-profile"
|
||||
|
||||
# Get the unique identifier used to test for the presence of Chris Titus Tech's PowerShell profile.
|
||||
$PSProfileIdentifier = (Invoke-RestMethod "https://api.github.com/repos/$GitHubRepoPath").full_name
|
||||
|
||||
# Check if Chris Titus Tech's PowerShell profile is currently installed in the PowerShell profile folder.
|
||||
if ((Get-Content $PSProfile) -match $PSProfileIdentifier) {
|
||||
# Attempt to uninstall Chris Titus Tech's PowerShell profile from the PowerShell profile folder.
|
||||
try {
|
||||
# Get the content of the backup PowerShell profile and store it in-memory.
|
||||
$PSProfileContent = Get-Content "$PSProfile.bak"
|
||||
|
||||
# Store the flag used to check if OhMyPosh is in use by the backup PowerShell profile.
|
||||
$OhMyPoshInUse = $PSProfileContent -match "oh-my-posh init"
|
||||
|
||||
# Check if OhMyPosh is not currently in use by the backup PowerShell profile.
|
||||
if (-not $OhMyPoshInUse) {
|
||||
# If OhMyPosh is currently installed attempt to uninstall it from the system.
|
||||
if (Get-Command oh-my-posh -ErrorAction SilentlyContinue) {
|
||||
# Let the user know that OhMyPosh is currently being uninstalled from their system.
|
||||
Write-Host "===> Uninstalling: OhMyPosh... <===" -ForegroundColor Yellow
|
||||
|
||||
# Attempt to uninstall OhMyPosh from the system with the WinGet package manager.
|
||||
winget uninstall -e --id JanDeDobbeleer.OhMyPosh
|
||||
}
|
||||
} else {
|
||||
# Let the user know that the uninstallation of OhMyPosh has been skipped because it is in use.
|
||||
Write-Host "===> Skipped Uninstall: OhMyPosh In-Use. <===" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
# Let the user know that an error was encountered when uninstalling OhMyPosh.
|
||||
Write-Host "Failed to uninstall OhMyPosh. Error: $_" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Attempt to uninstall the specified Nerd Fonts package from the system.
|
||||
try {
|
||||
# Specify the directory that the specified font package will be uninstalled from.
|
||||
[string]$FontsPath = "$env:LOCALAPPDATA\Microsoft\Windows\Fonts"
|
||||
|
||||
# Specify the name of the font package that is to be uninstalled from the system.
|
||||
[string]$FontFamilyName = "CaskaydiaCoveNerdFont"
|
||||
|
||||
# Call the function used to uninstall the specified Nerd Fonts package from the system.
|
||||
Uninstall-NerdFonts -FontsPath $FontsPath -FontFamilyName $FontFamilyName
|
||||
} catch {
|
||||
# Let the user know that an error was encountered when uninstalling Nerd Fonts.
|
||||
Write-Host "Failed to uninstall Nerd Fonts. Error: $_" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Attempt to uninstall the Terminal-Icons PowerShell module from the system.
|
||||
try {
|
||||
# Get the content of the backup PowerShell profile and store it in-memory.
|
||||
$PSProfileContent = Get-Content "$PSProfile.bak"
|
||||
|
||||
# Store the flag used to check if Terminal-Icons is in use by the backup PowerShell profile.
|
||||
$TerminalIconsInUse = $PSProfileContent -match "Import-Module" -and $PSProfileContent -match "Terminal-Icons"
|
||||
|
||||
# Check if Terminal-Icons is not currently in use by the backup PowerShell profile.
|
||||
if (-not $TerminalIconsInUse) {
|
||||
# If Terminal-Icons is currently installed attempt to uninstall it from the system.
|
||||
if (Get-Module -ListAvailable Terminal-Icons) {
|
||||
# Let the user know that Terminal-Icons is currently being uninstalled from their system.
|
||||
Write-Host "===> Uninstalling: Terminal-Icons... <===" -ForegroundColor Yellow
|
||||
|
||||
# Attempt to uninstall Terminal-Icons from the system with Uninstall-Module.
|
||||
Uninstall-Module -Name Terminal-Icons
|
||||
}
|
||||
} else {
|
||||
# Let the user know that the uninstallation of Terminal-Icons has been skipped because it is in use.
|
||||
Write-Host "===> Skipped Uninstall: Terminal-Icons In-Use. <===" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
# Let the user know that an error was encountered when uninstalling Terminal-Icons.
|
||||
Write-Host "Failed to uninstall Terminal-Icons. Error: $_" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Attempt to uninstall the Zoxide application from the system.
|
||||
try {
|
||||
# Get the content of the backup PowerShell profile and store it in-memory.
|
||||
$PSProfileContent = Get-Content "$PSProfile.bak"
|
||||
|
||||
# Store the flag used to check if Zoxide is in use by the backup PowerShell profile.
|
||||
$ZoxideInUse = $PSProfileContent -match "zoxide init"
|
||||
|
||||
# Check if Zoxide is not currently in use by the backup PowerShell profile.
|
||||
if (-not $ZoxideInUse) {
|
||||
# If Zoxide is currently installed attempt to uninstall it from the system.
|
||||
if (Get-Command zoxide -ErrorAction SilentlyContinue) {
|
||||
# Let the user know that Zoxide is currently being uninstalled from their system.
|
||||
Write-Host "===> Uninstalling: Zoxide... <===" -ForegroundColor Yellow
|
||||
|
||||
# Attempt to uninstall Zoxide from the system with the WinGet package manager.
|
||||
winget uninstall -e --id ajeetdsouza.zoxide
|
||||
}
|
||||
} else {
|
||||
# Let the user know that the uninstallation of Zoxide been skipped because it is in use.
|
||||
Write-Host "===> Skipped Uninstall: Zoxide In-Use. <===" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
# Let the user know that an error was encountered when uninstalling Zoxide.
|
||||
Write-Host "Failed to uninstall Zoxide. Error: $_" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Attempt to uninstall the CTT PowerShell profile from the system.
|
||||
try {
|
||||
# Try and remove the CTT PowerShell Profile file from the disk with Remove-Item.
|
||||
Remove-Item $PSProfile
|
||||
|
||||
# Let the user know that the CTT PowerShell profile has been uninstalled from the system.
|
||||
Write-Host "Profile has been uninstalled. Please restart your shell to reflect the changes!" -ForegroundColor Magenta
|
||||
} catch {
|
||||
# Let the user know that an error was encountered when uninstalling the profile.
|
||||
Write-Host "Failed to uninstall profile. Error: $_" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Attempt to move the user's original PowerShell profile backup back to its original location.
|
||||
try {
|
||||
# Check if the backup PowerShell profile exists before attempting to restore the backup.
|
||||
if (Test-Path "$PSProfile.bak") {
|
||||
# Restore the backup PowerShell profile and move it to its original location.
|
||||
Move-Item "$PSProfile.bak" $PSProfile
|
||||
|
||||
# Let the user know that their PowerShell profile backup has been successfully restored.
|
||||
Write-Host "===> Restored Profile Backup. <===" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
# Let the user know that an error was encountered when restoring the profile backup.
|
||||
Write-Host "Failed to restore profile backup. Error: $_" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Silently cleanup the oldprofile.ps1 file that was created when the CTT PowerShell profile was installed.
|
||||
Remove-Item "$env:USERPROFILE\oldprofile.ps1" | Out-Null
|
||||
} else {
|
||||
# Let the user know that the CTT PowerShell profile is not installed and that the uninstallation was skipped.
|
||||
Write-Host "===> Chris Titus Tech's PowerShell Profile Not Found. Skipped Uninstallation. <===" -ForegroundColor Magenta
|
||||
}
|
||||
} else {
|
||||
# Let the user know that no PowerShell profile was found and that the uninstallation was skipped.
|
||||
Write-Host "===> No PowerShell Profile Found. Skipped Uninstallation. <===" -ForegroundColor Magenta
|
||||
}
|
||||
}
|
||||
}
|
@ -35,11 +35,12 @@ function Set-WinUtilRegistry {
|
||||
New-Item -Path $Path -Force -ErrorAction Stop | Out-Null
|
||||
}
|
||||
|
||||
Write-Host "Set $Path\$Name to $Value"
|
||||
if ($Value -ne "<RemoveEntry>") {
|
||||
Write-Host "Set $Path\$Name to $Value"
|
||||
Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -Force -ErrorAction Stop | Out-Null
|
||||
}
|
||||
else{
|
||||
Write-Host "Remove $Path\$Name"
|
||||
Remove-ItemProperty -Path $Path -Name $Name -Force -ErrorAction Stop | Out-Null
|
||||
}
|
||||
} catch [System.Security.SecurityException] {
|
||||
|
@ -6,6 +6,9 @@ function Show-CustomDialog {
|
||||
.DESCRIPTION
|
||||
This function creates a custom dialog box with the specified message and additional elements such as an image, heading, and an OK button. The dialog box is designed with a green border, rounded corners, and a black background.
|
||||
|
||||
.PARAMETER Title
|
||||
The Title to use for the dialog window's Title Bar, this will not be visible by the user, as window styling is set to None.
|
||||
|
||||
.PARAMETER Message
|
||||
The message to be displayed in the dialog box.
|
||||
|
||||
@ -16,60 +19,102 @@ function Show-CustomDialog {
|
||||
The height of the custom dialog window.
|
||||
|
||||
.PARAMETER FontSize
|
||||
The Font Size for text shown inside the custom dialog window.
|
||||
The Font Size of message shown inside custom dialog window.
|
||||
|
||||
.PARAMETER HeaderFontSize
|
||||
The Font Size for the Header of the custom dialog window.
|
||||
The Font Size for the Header of custom dialog window.
|
||||
|
||||
.PARAMETER IconSize
|
||||
The Size to use for Icon inside the custom dialog window.
|
||||
.PARAMETER LogoSize
|
||||
The Size of the Logo used inside the custom dialog window.
|
||||
|
||||
.PARAMETER ForegroundColor
|
||||
The Foreground Color of dialog window title & message.
|
||||
|
||||
.PARAMETER BackgroundColor
|
||||
The Background Color of dialog window.
|
||||
|
||||
.PARAMETER BorderColor
|
||||
The Color for dialog window border.
|
||||
|
||||
.PARAMETER ButtonBackgroundColor
|
||||
The Background Color for Buttons in dialog window.
|
||||
|
||||
.PARAMETER ButtonForegroundColor
|
||||
The Foreground Color for Buttons in dialog window.
|
||||
|
||||
.PARAMETER ShadowColor
|
||||
The Color used when creating the Drop-down Shadow effect for dialog window.
|
||||
|
||||
.PARAMETER LogoColor
|
||||
The Color of WinUtil Text found next to WinUtil's Logo inside dialog window.
|
||||
|
||||
.PARAMETER LinkForegroundColor
|
||||
The Foreground Color for Links inside dialog window.
|
||||
|
||||
.PARAMETER LinkHoverForegroundColor
|
||||
The Foreground Color for Links when the mouse pointer hovers over them inside dialog window.
|
||||
|
||||
.PARAMETER EnableScroll
|
||||
A flag indicating whether to enable scrolling if the content exceeds the window size.
|
||||
|
||||
.EXAMPLE
|
||||
Show-CustomDialog -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200
|
||||
Show-CustomDialog -Title "My Custom Dialog" -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200
|
||||
|
||||
Makes a new Custom Dialog with the title 'My Custom Dialog' and a message 'This is a custom dialog with a message and an image above.', with dimensions of 300 by 200 pixels.
|
||||
Other styling options are grabbed from '$sync.Form.Resources' global variable.
|
||||
|
||||
.EXAMPLE
|
||||
$foregroundColor = New-Object System.Windows.Media.SolidColorBrush("#0088e5")
|
||||
$backgroundColor = New-Object System.Windows.Media.SolidColorBrush("#1e1e1e")
|
||||
$linkForegroundColor = New-Object System.Windows.Media.SolidColorBrush("#0088e5")
|
||||
$linkHoverForegroundColor = New-Object System.Windows.Media.SolidColorBrush("#005289")
|
||||
Show-CustomDialog -Title "My Custom Dialog" -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200 -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor -LinkForegroundColor $linkForegroundColor -LinkHoverForegroundColor $linkHoverForegroundColor
|
||||
|
||||
Makes a new Custom Dialog with the title 'My Custom Dialog' and a message 'This is a custom dialog with a message and an image above.', with dimensions of 300 by 200 pixels, with a link foreground (and general foreground) colors of '#0088e5', background color of '#1e1e1e', and Link Color on Hover of '005289', all of which are in Hexadecimal (the '#' Symbol is required by SolidColorBrush Constructor).
|
||||
Other styling options are grabbed from '$sync.Form.Resources' global variable.
|
||||
|
||||
#>
|
||||
param(
|
||||
[string]$Title,
|
||||
[string]$Message,
|
||||
[int]$Width = $sync.Form.Resources.CustomDialogWidth,
|
||||
[int]$Height = $sync.Form.Resources.CustomDialogHeight,
|
||||
|
||||
[System.Windows.Media.FontFamily]$FontFamily = $sync.Form.Resources.FontFamily,
|
||||
[int]$FontSize = $sync.Form.Resources.CustomDialogFontSize,
|
||||
[int]$HeaderFontSize = $sync.Form.Resources.CustomDialogFontSizeHeader,
|
||||
[int]$IconSize = $sync.Form.Resources.CustomDialogLogoSize,
|
||||
[int]$LogoSize = $sync.Form.Resources.CustomDialogLogoSize,
|
||||
|
||||
[System.Windows.Media.Color]$ShadowColor = "#AAAAAAAA",
|
||||
[System.Windows.Media.SolidColorBrush]$LogoColor = $sync.Form.Resources.LabelboxForegroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$BorderColor = $sync.Form.Resources.BorderColor,
|
||||
[System.Windows.Media.SolidColorBrush]$ForegroundColor = $sync.Form.Resources.MainForegroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$BackgroundColor = $sync.Form.Resources.MainBackgroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$ButtonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$ButtonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$LinkForegroundColor = $sync.Form.Resources.LinkForegroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$LinkHoverForegroundColor = $sync.Form.Resources.LinkHoverForegroundColor,
|
||||
|
||||
[bool]$EnableScroll = $false
|
||||
)
|
||||
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
|
||||
# Define theme colors
|
||||
$foregroundColor = $sync.Form.Resources.MainForegroundColor
|
||||
$backgroundColor = $sync.Form.Resources.MainBackgroundColor
|
||||
$font = New-Object Windows.Media.FontFamily("Consolas")
|
||||
$borderColor = $sync.Form.Resources.BorderColor # ButtonInstallBackgroundColor
|
||||
$buttonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor
|
||||
$buttonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor
|
||||
$shadowColor = [Windows.Media.ColorConverter]::ConvertFromString("#AAAAAAAA")
|
||||
$logocolor = $sync.Form.Resources.LabelboxForegroundColor
|
||||
|
||||
# Create a custom dialog window
|
||||
$dialog = New-Object Windows.Window
|
||||
$dialog.Title = "About"
|
||||
$dialog.Title = $Title
|
||||
$dialog.Height = $Height
|
||||
$dialog.Width = $Width
|
||||
$dialog.Margin = New-Object Windows.Thickness(10) # Add margin to the entire dialog box
|
||||
$dialog.WindowStyle = [Windows.WindowStyle]::None # Remove title bar and window controls
|
||||
$dialog.ResizeMode = [Windows.ResizeMode]::NoResize # Disable resizing
|
||||
$dialog.WindowStartupLocation = [Windows.WindowStartupLocation]::CenterScreen # Center the window
|
||||
$dialog.Foreground = $foregroundColor
|
||||
$dialog.Background = $backgroundColor
|
||||
$dialog.FontFamily = $font
|
||||
$dialog.Foreground = $ForegroundColor
|
||||
$dialog.Background = $BackgroundColor
|
||||
$dialog.FontFamily = $FontFamily
|
||||
$dialog.FontSize = $FontSize
|
||||
|
||||
# Create a Border for the green edge with rounded corners
|
||||
$border = New-Object Windows.Controls.Border
|
||||
$border.BorderBrush = $borderColor
|
||||
$border.BorderBrush = $BorderColor
|
||||
$border.BorderThickness = New-Object Windows.Thickness(1) # Adjust border thickness as needed
|
||||
$border.CornerRadius = New-Object Windows.CornerRadius(10) # Adjust the radius for rounded corners
|
||||
|
||||
@ -89,7 +134,7 @@ function Show-CustomDialog {
|
||||
$grid = New-Object Windows.Controls.Grid
|
||||
$border.Child = $grid
|
||||
|
||||
# Add the following line to show gridlines
|
||||
# Uncomment the following line to show gridlines
|
||||
#$grid.ShowGridLines = $true
|
||||
|
||||
# Add the following line to set the background color of the grid
|
||||
@ -102,7 +147,6 @@ function Show-CustomDialog {
|
||||
$border.HorizontalAlignment = [Windows.HorizontalAlignment]::Stretch
|
||||
$border.VerticalAlignment = [Windows.VerticalAlignment]::Stretch
|
||||
|
||||
|
||||
# Set up Row Definitions
|
||||
$row0 = New-Object Windows.Controls.RowDefinition
|
||||
$row0.Height = [Windows.GridLength]::Auto
|
||||
@ -129,17 +173,18 @@ function Show-CustomDialog {
|
||||
[Windows.Controls.Grid]::SetRow($stackPanel, 0) # Set the row to the second row (0-based index)
|
||||
|
||||
# Add SVG path to the stack panel
|
||||
$stackPanel.Children.Add((Invoke-WinUtilAssets -Type "logo" -Size 25))
|
||||
$stackPanel.Children.Add((Invoke-WinUtilAssets -Type "logo" -Size $LogoSize))
|
||||
|
||||
# Add "Winutil" text
|
||||
$winutilTextBlock = New-Object Windows.Controls.TextBlock
|
||||
$winutilTextBlock.Text = "Winutil"
|
||||
$winutilTextBlock.FontSize = $HeaderFontSize
|
||||
$winutilTextBlock.Foreground = $logocolor
|
||||
$winutilTextBlock.Foreground = $LogoColor
|
||||
$winutilTextBlock.Margin = New-Object Windows.Thickness(10, 10, 10, 5) # Add margins around the text block
|
||||
$stackPanel.Children.Add($winutilTextBlock)
|
||||
# Add TextBlock for information with text wrapping and margins
|
||||
$messageTextBlock = New-Object Windows.Controls.TextBlock
|
||||
$messageTextBlock.FontSize = $FontSize
|
||||
$messageTextBlock.TextWrapping = [Windows.TextWrapping]::Wrap # Enable text wrapping
|
||||
$messageTextBlock.HorizontalAlignment = [Windows.HorizontalAlignment]::Left
|
||||
$messageTextBlock.VerticalAlignment = [Windows.VerticalAlignment]::Top
|
||||
@ -162,7 +207,7 @@ function Show-CustomDialog {
|
||||
$hyperlink.NavigateUri = New-Object System.Uri($match.Groups[1].Value)
|
||||
$hyperlink.Inlines.Add($match.Groups[2].Value)
|
||||
$hyperlink.TextDecorations = [Windows.TextDecorations]::None # Remove underline
|
||||
$hyperlink.Foreground = $sync.Form.Resources.LinkForegroundColor
|
||||
$hyperlink.Foreground = $LinkForegroundColor
|
||||
|
||||
$hyperlink.Add_Click({
|
||||
param($sender, $args)
|
||||
@ -170,11 +215,15 @@ function Show-CustomDialog {
|
||||
})
|
||||
$hyperlink.Add_MouseEnter({
|
||||
param($sender, $args)
|
||||
$sender.Foreground = $sync.Form.Resources.LinkHoverForegroundColor
|
||||
$sender.Foreground = $LinkHoverForegroundColor
|
||||
$sender.FontSize = ($FontSize + ($FontSize / 4))
|
||||
$sender.FontWeight = "SemiBold"
|
||||
})
|
||||
$hyperlink.Add_MouseLeave({
|
||||
param($sender, $args)
|
||||
$sender.Foreground = $sync.Form.Resources.LinkForegroundColor
|
||||
$sender.Foreground = $LinkForegroundColor
|
||||
$sender.FontSize = $FontSize
|
||||
$sender.FontWeight = "Normal"
|
||||
})
|
||||
|
||||
$messageTextBlock.Inlines.Add($hyperlink)
|
||||
@ -218,7 +267,7 @@ function Show-CustomDialog {
|
||||
$okButton.Margin = New-Object Windows.Thickness(0, 0, 0, 10)
|
||||
$okButton.Background = $buttonBackgroundColor
|
||||
$okButton.Foreground = $buttonForegroundColor
|
||||
$okButton.BorderBrush = $borderColor
|
||||
$okButton.BorderBrush = $BorderColor
|
||||
$okButton.Add_Click({
|
||||
$dialog.Close()
|
||||
})
|
||||
|
@ -50,13 +50,15 @@ function Invoke-WPFButton {
|
||||
"WPFFixesNetwork" {Invoke-WPFFixesNetwork}
|
||||
"WPFUpdatesdisable" {Invoke-WPFUpdatesdisable}
|
||||
"WPFUpdatessecurity" {Invoke-WPFUpdatessecurity}
|
||||
"WPFWinUtilShortcut" {Invoke-WPFShortcut -ShortcutToAdd "WinUtil" -RunAsAdmin $true}
|
||||
"WPFGetInstalled" {Invoke-WPFGetInstalled -CheckBox "winget"}
|
||||
"WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"}
|
||||
"WPFGetIso" {Invoke-MicrowinGetIso}
|
||||
"WPFMicrowin" {Invoke-Microwin}
|
||||
"WPFCloseButton" {Invoke-WPFCloseButton}
|
||||
"MicrowinScratchDirBT" {Invoke-ScratchDialog}
|
||||
"WPFWinUtilPSProfile" {Invoke-WinUtilpsProfile}
|
||||
"WPFWinUtilInstallPSProfile" {Invoke-WinUtilInstallPSProfile}
|
||||
"WPFWinUtilUninstallPSProfile" {Invoke-WinUtilUninstallPSProfile}
|
||||
"WPFWinUtilSSHServer" {Invoke-WinUtilSSHServer}
|
||||
}
|
||||
}
|
||||
|
54
functions/public/Invoke-WPFPopup.ps1
Normal file
54
functions/public/Invoke-WPFPopup.ps1
Normal file
@ -0,0 +1,54 @@
|
||||
function Invoke-WPFPopup {
|
||||
param (
|
||||
[ValidateSet("Show", "Hide", "Toggle")]
|
||||
[string]$Action = "",
|
||||
|
||||
[string[]]$Popups = @(),
|
||||
|
||||
[ValidateScript({
|
||||
$invalid = $_.GetEnumerator() | Where-Object { $_.Value -notin @("Show", "Hide", "Toggle") }
|
||||
if ($invalid) {
|
||||
throw "Found invalid Popup-Action pair(s): " + ($invalid | ForEach-Object { "$($_.Key) = $($_.Value)" } -join "; ")
|
||||
}
|
||||
$true
|
||||
})]
|
||||
[hashtable]$PopupActionTable = @{}
|
||||
)
|
||||
|
||||
if (-not $PopupActionTable.Count -and (-not $Action -or -not $Popups.Count)) {
|
||||
throw "Provide either 'PopupActionTable' or both 'Action' and 'Popups'."
|
||||
}
|
||||
|
||||
if ($PopupActionTable.Count -and ($Action -or $Popups.Count)) {
|
||||
throw "Use 'PopupActionTable' on its own, or 'Action' with 'Popups'."
|
||||
}
|
||||
|
||||
# Collect popups and actions
|
||||
$PopupsToProcess = if ($PopupActionTable.Count) {
|
||||
$PopupActionTable.GetEnumerator() | ForEach-Object { [PSCustomObject]@{ Name = "$($_.Key)Popup"; Action = $_.Value } }
|
||||
} else {
|
||||
$Popups | ForEach-Object { [PSCustomObject]@{ Name = "$_`Popup"; Action = $Action } }
|
||||
}
|
||||
|
||||
$PopupsNotFound = @()
|
||||
|
||||
# Apply actions
|
||||
foreach ($popupEntry in $PopupsToProcess) {
|
||||
$popupName = $popupEntry.Name
|
||||
|
||||
if (-not $sync.$popupName) {
|
||||
$PopupsNotFound += $popupName
|
||||
continue
|
||||
}
|
||||
|
||||
$sync.$popupName.IsOpen = switch ($popupEntry.Action) {
|
||||
"Show" { $true }
|
||||
"Hide" { $false }
|
||||
"Toggle" { -not $sync.$popupName.IsOpen }
|
||||
}
|
||||
}
|
||||
|
||||
if ($PopupsNotFound.Count -gt 0) {
|
||||
throw "Could not find the following popups: $($PopupsNotFound -join ', ')"
|
||||
}
|
||||
}
|
@ -142,7 +142,7 @@ function Invoke-WPFUIElements {
|
||||
|
||||
$label = New-Object Windows.Controls.Label
|
||||
$label.Content = $category -replace ".*__", ""
|
||||
$label.FontSize = $theme.FontSizeHeading
|
||||
$label.FontSize = $theme.HeadingFontSize
|
||||
$label.FontFamily = $theme.HeaderFontFamily
|
||||
$stackPanel.Children.Add($label) | Out-Null
|
||||
|
||||
|
123
scripts/main.ps1
123
scripts/main.ps1
@ -31,23 +31,20 @@ $sync.runspace.Open()
|
||||
|
||||
# Create classes for different exceptions
|
||||
|
||||
class WingetFailedInstall : Exception {
|
||||
[string]$additionalData
|
||||
class WingetFailedInstall : Exception {
|
||||
[string]$additionalData
|
||||
WingetFailedInstall($Message) : base($Message) {}
|
||||
}
|
||||
|
||||
WingetFailedInstall($Message) : base($Message) {}
|
||||
}
|
||||
class ChocoFailedInstall : Exception {
|
||||
[string]$additionalData
|
||||
ChocoFailedInstall($Message) : base($Message) {}
|
||||
}
|
||||
|
||||
class ChocoFailedInstall : Exception {
|
||||
[string]$additionalData
|
||||
|
||||
ChocoFailedInstall($Message) : base($Message) {}
|
||||
}
|
||||
|
||||
class GenericException : Exception {
|
||||
[string]$additionalData
|
||||
|
||||
GenericException($Message) : base($Message) {}
|
||||
}
|
||||
class GenericException : Exception {
|
||||
[string]$additionalData
|
||||
GenericException($Message) : base($Message) {}
|
||||
}
|
||||
|
||||
|
||||
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
||||
@ -254,12 +251,7 @@ $commonKeyEvents = {
|
||||
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
|
||||
|
||||
$sync["Form"].Add_MouseLeftButtonDown({
|
||||
# Hide Settings and Theme Popup on click anywhere else
|
||||
if ($sync.SettingsButton.IsOpen -or
|
||||
$sync.ThemePopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme")
|
||||
$sync["Form"].DragMove()
|
||||
})
|
||||
|
||||
@ -277,12 +269,7 @@ $sync["Form"].Add_MouseDoubleClick({
|
||||
|
||||
$sync["Form"].Add_Deactivated({
|
||||
Write-Debug "WinUtil lost focus"
|
||||
# Hide Settings and Theme Popup on Winutil Focus Loss
|
||||
if ($sync.SettingsButton.IsOpen -or
|
||||
$sync.ThemePopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme")
|
||||
})
|
||||
|
||||
$sync["Form"].Add_ContentRendered({
|
||||
@ -521,101 +508,79 @@ Set-WinUtilTaskbaritem -overlay "logo"
|
||||
$sync["Form"].Add_Activated({
|
||||
Set-WinUtilTaskbaritem -overlay "logo"
|
||||
})
|
||||
# Define event handler for ThemeButton click
|
||||
$sync["ThemeButton"].Add_Click({
|
||||
if ($sync.ThemePopup.IsOpen) {
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
else{
|
||||
$sync.ThemePopup.IsOpen = $true
|
||||
}
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
})
|
||||
|
||||
# Define event handlers for menu items
|
||||
$sync["ThemeButton"].Add_Click({
|
||||
Write-Debug "ThemeButton clicked"
|
||||
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Hide"; "Theme" = "Toggle" }
|
||||
$_.Handled = $false
|
||||
})
|
||||
$sync["AutoThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Write-Debug "About clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Auto"
|
||||
$_.Handled = $false
|
||||
})
|
||||
# Define event handlers for menu items
|
||||
})
|
||||
$sync["DarkThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Write-Debug "Dark Theme clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Dark"
|
||||
$_.Handled = $false
|
||||
})
|
||||
# Define event handlers for menu items
|
||||
})
|
||||
$sync["LightThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Write-Debug "Light Theme clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Light"
|
||||
$_.Handled = $false
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
# Define event handler for button click
|
||||
$sync["SettingsButton"].Add_Click({
|
||||
Write-Debug "SettingsButton clicked"
|
||||
if ($sync.SettingsPopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
}
|
||||
else{
|
||||
$sync.SettingsPopup.IsOpen = $true
|
||||
}
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Toggle"; "Theme" = "Hide" }
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
# Define event handlers for menu items
|
||||
$sync["ImportMenuItem"].Add_Click({
|
||||
# Handle Import menu item click
|
||||
Write-Debug "Import clicked"
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
Invoke-WPFImpex -type "import"
|
||||
$_.Handled = $false
|
||||
Write-Debug "Import clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
Invoke-WPFImpex -type "import"
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
$sync["ExportMenuItem"].Add_Click({
|
||||
# Handle Export menu item click
|
||||
Write-Debug "Export clicked"
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
Invoke-WPFImpex -type "export"
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
$sync["AboutMenuItem"].Add_Click({
|
||||
# Handle Export menu item click
|
||||
Write-Debug "About clicked"
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
|
||||
$authorInfo = @"
|
||||
Author : <a href="https://github.com/ChrisTitusTech">@christitustech</a>
|
||||
Runspace : <a href="https://github.com/DeveloperDurp">@DeveloperDurp</a>
|
||||
MicroWin : <a href="https://github.com/KonTy">@KonTy</a>
|
||||
MicroWin : <a href="https://github.com/KonTy">@KonTy</a>, <a href="https://github.com/CodingWonders">@CodingWonders</a>
|
||||
GitHub : <a href="https://github.com/ChrisTitusTech/winutil">ChrisTitusTech/winutil</a>
|
||||
Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sync.version)">$($sync.version)</a>
|
||||
"@
|
||||
|
||||
Show-CustomDialog -Message $authorInfo -LogoSize $LogoSize
|
||||
Show-CustomDialog -Title "About" -Message $authorInfo
|
||||
})
|
||||
|
||||
$sync["SponsorMenuItem"].Add_Click({
|
||||
# Handle Export menu item click
|
||||
Write-Debug "Sponsors clicked"
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
|
||||
$authorInfo = @"
|
||||
<a href="https://github.com/sponsors/ChrisTitusTech">Current sponsors for ChrisTitusTech:</a>
|
||||
"@
|
||||
$authorInfo += "`n"
|
||||
try {
|
||||
# Call the function to get the sponsors
|
||||
$sponsors = Invoke-WinUtilSponsors
|
||||
|
||||
# Append the sponsors to the authorInfo
|
||||
$sponsors | ForEach-Object { $authorInfo += "$_`n" }
|
||||
foreach ($sponsor in $sponsors) {
|
||||
$authorInfo += "<a href=`"https://github.com/sponsors/ChrisTitusTech`">$sponsor</a>`n"
|
||||
}
|
||||
} catch {
|
||||
$authorInfo += "An error occurred while fetching or processing the sponsors: $_`n"
|
||||
}
|
||||
|
||||
Show-CustomDialog -Message $authorInfo -EnableScroll $true
|
||||
Show-CustomDialog -Title "Sponsors" -Message $authorInfo -EnableScroll $true
|
||||
})
|
||||
|
||||
$sync["Form"].ShowDialog() | out-null
|
||||
|
@ -30,7 +30,7 @@ function RedirectToLatestPreRelease {
|
||||
if ($latestRelease) {
|
||||
$url = "https://github.com/ChrisTitusTech/winutil/releases/download/$latestRelease/winutil.ps1"
|
||||
} else {
|
||||
Write-Host 'Unable to determine latest pre-release version.' -ForegroundColor Red
|
||||
Write-Host 'No pre-release version found. This is most likely because the latest release is a full release and no newer pre-release exists.' -ForegroundColor Yellow
|
||||
Write-Host "Using latest Full Release"
|
||||
$url = "https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1"
|
||||
}
|
||||
|
@ -1004,19 +1004,19 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Row="0" Grid.Column="0" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
|
||||
<Button Name="WPFUpdatesdefault" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Default (Out of Box) Settings" Margin="20,4,20,10" Padding="10"/>
|
||||
<Button Name="WPFUpdatesdefault" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Default (Out of Box) Settings" Margin="20,4,20,10" Padding="10"/>
|
||||
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is the default settings that come with Windows. <LineBreak/><LineBreak/> No modifications are made and will remove any custom windows update settings.<LineBreak/><LineBreak/>Note: If you still encounter update errors, reset all updates in the config tab. That will restore ALL Microsoft Update Services from their servers and reinstall them to default settings.</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="1" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
|
||||
<Button Name="WPFUpdatessecurity" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Security (Recommended) Settings" Margin="20,4,20,10" Padding="10"/>
|
||||
<Button Name="WPFUpdatessecurity" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Security (Recommended) Settings" Margin="20,4,20,10" Padding="10"/>
|
||||
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is my recommended setting I use on all computers.<LineBreak/><LineBreak/> It will delay feature updates by 2 years and will install security updates 4 days after release.<LineBreak/><LineBreak/>Feature Updates: Adds features and often bugs to systems when they are released. You want to delay these as long as possible.<LineBreak/><LineBreak/>Security Updates: Typically these are pressing security flaws that need to be patched quickly. You only want to delay these a couple of days just to see if they are safe and don't break other systems. You don't want to go without these for ANY extended periods of time.</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="2" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
|
||||
<Button Name="WPFUpdatesdisable" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Disable ALL Updates (NOT RECOMMENDED!)" Margin="20,4,20,10" Padding="10,10,10,10"/>
|
||||
<Button Name="WPFUpdatesdisable" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Disable ALL Updates (NOT RECOMMENDED!)" Margin="20,4,20,10" Padding="10,10,10,10"/>
|
||||
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This completely disables ALL Windows Updates and is NOT RECOMMENDED.<LineBreak/><LineBreak/> However, it can be suitable if you use your system for a select purpose and do not actively browse the internet. <LineBreak/><LineBreak/>Note: Your system will be easier to hack and infect without security updates.</TextBlock>
|
||||
<TextBlock Text=" " Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300"/>
|
||||
</StackPanel>
|
||||
|
Loading…
Reference in New Issue
Block a user