Compare commits

...

11 Commits

Author SHA1 Message Date
14c6562bf6 Create Invoke-WinUtilInteractiveNerdFontInstall.ps1
Using this script, we could integrate inside of the XAML, a list of all current nerdfonts, and user can choose which to install.

https://raw.githubusercontent.com/jpawlowski/nerd-fonts-installer-PS/main/Invoke-NerdFontInstaller.ps1

I am not sure how to add it into xaml :  - (
2025-01-30 18:37:35 -04:00
c2fb98b0dc Deploying to main from @ ChrisTitusTech/winutil@cf8787a700 🚀 2025-01-30 15:32:01 +00:00
cf8787a700 Fixed impartial nerd font uninstallation (#3171)
* fix: nerdfonts uninstall now deletes corresponding registry keys

* change ErrorAction to SilentlyContinue

* fix some code styling

* removed unused files/docs as per Cryostrixx advice

* restored portions of the feature.json
2025-01-28 13:59:00 -06:00
53b723fa11 update application.json (#3166) 2025-01-28 13:50:31 -06:00
32cb94f392 [MicroWin] Fixed divide by zero error for fallback (#3174)
<Insert the never mind - misspelled a variable meme here>
2025-01-28 11:03:35 -06:00
5550e40270 Deploying to main from @ ChrisTitusTech/winutil@bcecf67c7d 🚀 2025-01-28 15:32:37 +00:00
bcecf67c7d Deploying to main from @ ChrisTitusTech/winutil@3b50ff813c 🚀 2025-01-27 15:30:51 +00:00
3b50ff813c Deploying to main from @ ChrisTitusTech/winutil@eba5b35978 🚀 2025-01-26 15:30:58 +00:00
eba5b35978 Deploying to main from @ ChrisTitusTech/winutil@254738a420 🚀 2025-01-20 15:32:07 +00:00
254738a420 Use HTTPS instead of HTTP for URLs where supported. (#3161) 2025-01-17 08:42:42 -06:00
bcc801683d [Tweaks] Disable output for DISM for the Recall tweak (#3154)
* Fixed lock caused by expected input for DISM

This is the main event

* Miscellaneous file

Don't know why this file was modified by the compile preprocessor
2025-01-17 08:40:04 -06:00
16 changed files with 235 additions and 146 deletions

View File

@ -52,7 +52,7 @@ If you have Issues, refer to [Known Issues](https://christitustech.github.io/win
These are the sponsors that help keep this project alive with monthly contributions. These are the sponsors that help keep this project alive with monthly contributions.
<!-- sponsors --><a href="https://github.com/TriHydera"><img src="https:&#x2F;&#x2F;github.com&#x2F;TriHydera.png" width="60px" alt="User avatar: TriHydera" /></a><a href="https://github.com/jozozovko"><img src="https:&#x2F;&#x2F;github.com&#x2F;jozozovko.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DelDongo"><img src="https:&#x2F;&#x2F;github.com&#x2F;DelDongo.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/markamos"><img src="https:&#x2F;&#x2F;github.com&#x2F;markamos.png" width="60px" alt="User avatar: Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https:&#x2F;&#x2F;github.com&#x2F;dwelfusius.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/mews-se"><img src="https:&#x2F;&#x2F;github.com&#x2F;mews-se.png" width="60px" alt="User avatar: Martin Stockzell" /></a><a href="https://github.com/jdiegmueller"><img src="https:&#x2F;&#x2F;github.com&#x2F;jdiegmueller.png" width="60px" alt="User avatar: Jason A. Diegmueller" /></a><a href="https://github.com/AlanTristar"><img src="https:&#x2F;&#x2F;github.com&#x2F;AlanTristar.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/zepled112"><img src="https:&#x2F;&#x2F;github.com&#x2F;zepled112.png" width="60px" alt="User avatar: wyatt" /></a><a href="https://github.com/altugtekiner"><img src="https:&#x2F;&#x2F;github.com&#x2F;altugtekiner.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/robertsandrock"><img src="https:&#x2F;&#x2F;github.com&#x2F;robertsandrock.png" width="60px" alt="User avatar: RMS" /></a><a href="https://github.com/KenichiQaz"><img src="https:&#x2F;&#x2F;github.com&#x2F;KenichiQaz.png" width="60px" alt="User avatar: Stefan" /></a><a href="https://github.com/paulsheets"><img src="https:&#x2F;&#x2F;github.com&#x2F;paulsheets.png" width="60px" alt="User avatar: Paul" /></a><a href="https://github.com/djones369"><img src="https:&#x2F;&#x2F;github.com&#x2F;djones369.png" width="60px" alt="User avatar: Dave Jones" /></a><a href="https://github.com/anthonymendez"><img src="https:&#x2F;&#x2F;github.com&#x2F;anthonymendez.png" width="60px" alt="User avatar: Anthony Mendez" /></a><a href="https://github.com/claudemods"><img src="https:&#x2F;&#x2F;github.com&#x2F;claudemods.png" width="60px" alt="User avatar: Claudemods" /></a><a href="https://github.com/FatBastard0"><img src="https:&#x2F;&#x2F;github.com&#x2F;FatBastard0.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/Ascent7910"><img src="https:&#x2F;&#x2F;github.com&#x2F;Ascent7910.png" width="60px" alt="User avatar: Max" /></a><a href="https://github.com/DursleyGuy"><img src="https:&#x2F;&#x2F;github.com&#x2F;DursleyGuy.png" width="60px" alt="User avatar: DursleyGuy" /></a><a href="https://github.com/YamiSandman616"><img src="https:&#x2F;&#x2F;github.com&#x2F;YamiSandman616.png" width="60px" alt="User avatar: Sandman616" /></a><a href="https://github.com/realmuddy"><img src="https:&#x2F;&#x2F;github.com&#x2F;realmuddy.png" width="60px" alt="User avatar: Phillip Waters" /></a><a href="https://github.com/quaszi"><img src="https:&#x2F;&#x2F;github.com&#x2F;quaszi.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/EgoRaInevitable"><img src="https:&#x2F;&#x2F;github.com&#x2F;EgoRaInevitable.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/Unambiguous"><img src="https:&#x2F;&#x2F;github.com&#x2F;Unambiguous.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/Freestyler589"><img src="https:&#x2F;&#x2F;github.com&#x2F;Freestyler589.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/EA-1356"><img src="https:&#x2F;&#x2F;github.com&#x2F;EA-1356.png" width="60px" alt="User avatar: meris" /></a><!-- sponsors --> <!-- sponsors --><a href="https://github.com/TriHydera"><img src="https:&#x2F;&#x2F;github.com&#x2F;TriHydera.png" width="60px" alt="User avatar: TriHydera" /></a><a href="https://github.com/jozozovko"><img src="https:&#x2F;&#x2F;github.com&#x2F;jozozovko.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/DelDongo"><img src="https:&#x2F;&#x2F;github.com&#x2F;DelDongo.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/markamos"><img src="https:&#x2F;&#x2F;github.com&#x2F;markamos.png" width="60px" alt="User avatar: Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https:&#x2F;&#x2F;github.com&#x2F;dwelfusius.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/mews-se"><img src="https:&#x2F;&#x2F;github.com&#x2F;mews-se.png" width="60px" alt="User avatar: Martin Stockzell" /></a><a href="https://github.com/jdiegmueller"><img src="https:&#x2F;&#x2F;github.com&#x2F;jdiegmueller.png" width="60px" alt="User avatar: Jason A. Diegmueller" /></a><a href="https://github.com/altugtekiner"><img src="https:&#x2F;&#x2F;github.com&#x2F;altugtekiner.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/robertsandrock"><img src="https:&#x2F;&#x2F;github.com&#x2F;robertsandrock.png" width="60px" alt="User avatar: RMS" /></a><a href="https://github.com/KenichiQaz"><img src="https:&#x2F;&#x2F;github.com&#x2F;KenichiQaz.png" width="60px" alt="User avatar: Stefan" /></a><a href="https://github.com/paulsheets"><img src="https:&#x2F;&#x2F;github.com&#x2F;paulsheets.png" width="60px" alt="User avatar: Paul" /></a><a href="https://github.com/djones369"><img src="https:&#x2F;&#x2F;github.com&#x2F;djones369.png" width="60px" alt="User avatar: Dave Jones" /></a><a href="https://github.com/anthonymendez"><img src="https:&#x2F;&#x2F;github.com&#x2F;anthonymendez.png" width="60px" alt="User avatar: Anthony Mendez" /></a><a href="https://github.com/claudemods"><img src="https:&#x2F;&#x2F;github.com&#x2F;claudemods.png" width="60px" alt="User avatar: Claudemods" /></a><a href="https://github.com/FatBastard0"><img src="https:&#x2F;&#x2F;github.com&#x2F;FatBastard0.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/Ascent7910"><img src="https:&#x2F;&#x2F;github.com&#x2F;Ascent7910.png" width="60px" alt="User avatar: Max" /></a><a href="https://github.com/DursleyGuy"><img src="https:&#x2F;&#x2F;github.com&#x2F;DursleyGuy.png" width="60px" alt="User avatar: DursleyGuy" /></a><a href="https://github.com/YamiSandman616"><img src="https:&#x2F;&#x2F;github.com&#x2F;YamiSandman616.png" width="60px" alt="User avatar: Sandman616" /></a><a href="https://github.com/realmuddy"><img src="https:&#x2F;&#x2F;github.com&#x2F;realmuddy.png" width="60px" alt="User avatar: Phillip Waters" /></a><a href="https://github.com/quaszi"><img src="https:&#x2F;&#x2F;github.com&#x2F;quaszi.png" width="60px" alt="User avatar: " /></a><a href="https://github.com/EA-1356"><img src="https:&#x2F;&#x2F;github.com&#x2F;EA-1356.png" width="60px" alt="User avatar: toranaga" /></a><!-- sponsors -->
## 🏅 Thanks to all Contributors ## 🏅 Thanks to all Contributors
Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻. Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻.

View File

@ -916,7 +916,7 @@
"choco": "imgburn", "choco": "imgburn",
"content": "ImgBurn", "content": "ImgBurn",
"description": "ImgBurn is a lightweight CD, DVD, HD-DVD, and Blu-ray burning application with advanced features for creating and burning disc images.", "description": "ImgBurn is a lightweight CD, DVD, HD-DVD, and Blu-ray burning application with advanced features for creating and burning disc images.",
"link": "http://www.imgburn.com/", "link": "https://www.imgburn.com/",
"winget": "LIGHTNINGUK.ImgBurn" "winget": "LIGHTNINGUK.ImgBurn"
}, },
"inkscape": { "inkscape": {
@ -988,7 +988,7 @@
"choco": "jdownloader", "choco": "jdownloader",
"content": "JDownloader", "content": "JDownloader",
"description": "JDownloader is a feature-rich download manager with support for various file hosting services.", "description": "JDownloader is a feature-rich download manager with support for various file hosting services.",
"link": "http://jdownloader.org/", "link": "https://jdownloader.org/",
"winget": "AppWork.JDownloader" "winget": "AppWork.JDownloader"
}, },
"jellyfinmediaplayer": { "jellyfinmediaplayer": {
@ -1380,7 +1380,7 @@
"choco": "na", "choco": "na",
"content": "nGlide (3dfx compatibility)", "content": "nGlide (3dfx compatibility)",
"description": "nGlide is a 3Dfx Voodoo Glide wrapper. It allows you to play games that use Glide API on modern graphics cards without the need for a 3Dfx Voodoo graphics card.", "description": "nGlide is a 3Dfx Voodoo Glide wrapper. It allows you to play games that use Glide API on modern graphics cards without the need for a 3Dfx Voodoo graphics card.",
"link": "http://www.zeus-software.com/downloads/nglide", "link": "https://www.zeus-software.com/downloads/nglide",
"winget": "ZeusSoftware.nGlide" "winget": "ZeusSoftware.nGlide"
}, },
"nmap": { "nmap": {
@ -2204,7 +2204,7 @@
"choco": "na", "choco": "na",
"content": "Thorium Browser AVX2", "content": "Thorium Browser AVX2",
"description": "Browser built for speed over vanilla chromium. It is built with AVX2 optimizations and is the fastest browser on the market.", "description": "Browser built for speed over vanilla chromium. It is built with AVX2 optimizations and is the fastest browser on the market.",
"link": "http://thorium.rocks/", "link": "https://thorium.rocks/",
"winget": "Alex313031.Thorium.AVX2" "winget": "Alex313031.Thorium.AVX2"
}, },
"thunderbird": { "thunderbird": {
@ -2461,7 +2461,7 @@
"content": "UniGetUI", "content": "UniGetUI",
"description": "UniGetUI is a GUI for Winget, Chocolatey, and other Windows CLI package managers.", "description": "UniGetUI is a GUI for Winget, Chocolatey, and other Windows CLI package managers.",
"link": "https://www.marticliment.com/wingetui/", "link": "https://www.marticliment.com/wingetui/",
"winget": "SomePythonThings.WingetUIStore" "winget": "MartiCliment.UniGetUI"
}, },
"winmerge": { "winmerge": {
"category": "Document", "category": "Document",

View File

@ -312,8 +312,7 @@
"panel": "2", "panel": "2",
"Order": "a083_", "Order": "a083_",
"Type": "Button", "Type": "Button",
"ButtonWidth": "300", "ButtonWidth": "300"
"link": "https://christitustech.github.io/winutil/dev/features/Powershell-Profile/PSProfileInstall"
}, },
"WPFWinUtilUninstallPSProfile": { "WPFWinUtilUninstallPSProfile": {
"Content": "Uninstall CTT PowerShell Profile", "Content": "Uninstall CTT PowerShell Profile",
@ -321,8 +320,7 @@
"panel": "2", "panel": "2",
"Order": "a084_", "Order": "a084_",
"Type": "Button", "Type": "Button",
"ButtonWidth": "300", "ButtonWidth": "300"
"link": "https://christitustech.github.io/winutil/dev/features/Powershell-Profile/PSProfileUninstall"
}, },
"WPFWinUtilSSHServer": { "WPFWinUtilSSHServer": {
"Content": "Enable OpenSSH Server", "Content": "Enable OpenSSH Server",

View File

@ -2596,13 +2596,15 @@
"InvokeScript": [ "InvokeScript": [
" "
Write-Host \"Disable Recall\" Write-Host \"Disable Recall\"
DISM /Online /Disable-Feature /FeatureName:Recall DISM /Online /Disable-Feature /FeatureName:Recall /Quiet /NoRestart
Write-Host \"Please restart your computer in order for the changes to be fully applied.\"
" "
], ],
"UndoScript": [ "UndoScript": [
" "
Write-Host \"Enable Recall\" Write-Host \"Enable Recall\"
DISM /Online /Enable-Feature /FeatureName:Recall DISM /Online /Enable-Feature /FeatureName:Recall /Quiet /NoRestart
Write-Host \"Please restart your computer in order for the changes to be fully applied.\"
" "
], ],
"link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/DisableRecall" "link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/DisableRecall"

View File

@ -6,7 +6,7 @@
#### **Run the latest pre-release** #### **Run the latest pre-release**
```ps1 ```ps1
irm christitus.com/windev | iex irm https://christitus.com/windev | iex
``` ```
!!! bug "Keep in mind" !!! bug "Keep in mind"

View File

@ -6,7 +6,7 @@ Windows Security (formerly Defender) and other anti-virus software are known to
To resolve this, allow/whitelist the script in your anti-virus software settings, or temporarily disable real-time protection. Since the project is open source, you may audit the code if security is a concern. To resolve this, allow/whitelist the script in your anti-virus software settings, or temporarily disable real-time protection. Since the project is open source, you may audit the code if security is a concern.
### Download not working ### Download not working
If `christitus.com/win` is not working, or you want to download the code from GitHub directly, you can use the direct download link: If `https://christitus.com/win` is not working, or you want to download the code from GitHub directly, you can use the direct download link:
```ps1 ```ps1
irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1 | iex irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1 | iex
@ -34,7 +34,7 @@ If you are still having issues, try using a **VPN**, or changing your **DNS prov
2. In the PowerShell window, type this to allow unsigned code to execute and run the installation script: 2. In the PowerShell window, type this to allow unsigned code to execute and run the installation script:
```ps1 ```ps1
Set-ExecutionPolicy Unrestricted -Scope Process -Force Set-ExecutionPolicy Unrestricted -Scope Process -Force
irm christitus.com/win | iex irm https://christitus.com/win | iex
``` ```
## Runtime Issues ## Runtime Issues

View File

@ -1,38 +0,0 @@
# 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)

View File

@ -1,38 +0,0 @@
# 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)

View File

@ -11,7 +11,7 @@ Welcome to the official documentation for WinUtil, your go-to utility for optimi
* You will first need to start a Powershell terminal **as Admin**. * You will first need to start a Powershell terminal **as Admin**.
* Now you can run the following command: * Now you can run the following command:
```ps1 ```ps1
irm christitus.com/win | iex irm https://christitus.com/win | iex
``` ```
!!! info !!! info

View File

@ -258,6 +258,6 @@ With MicroWin, you can also configure your user before proceeding if you don't w
* On any supported Windows machine, open PowerShell **as Admin** and run the following command to automatically apply tweaks and install apps from the config file. * On any supported Windows machine, open PowerShell **as Admin** and run the following command to automatically apply tweaks and install apps from the config file.
```ps1 ```ps1
iex "& { $(irm christitus.com/win) } -Config [path-to-your-config] -Run" iex "& { $(irm https://christitus.com/win) } -Config [path-to-your-config] -Run"
``` ```
* Have a cup of coffee! Come back when it's done. * Have a cup of coffee! Come back when it's done.

View File

@ -88,7 +88,7 @@ function Microwin-RemovePackages {
} else { } else {
foreach ($package in $pkgList) { foreach ($package in $pkgList) {
$status = "Removing package $package" $status = "Removing package $package"
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$featlist.Count*100) Write-Progress -Activity "Removing Packages" -Status $status -PercentComplete ($counter++/$pkglist.Count*100)
Write-Debug "Removing package $package" Write-Debug "Removing package $package"
dism /english /image="$scratchDir" /remove-package /packagename=$package /remove /quiet /norestart | Out-Null dism /english /image="$scratchDir" /remove-package /packagename=$package /remove /quiet /norestart | Out-Null
if ($? -eq $false) { if ($? -eq $false) {

View File

@ -0,0 +1,171 @@
function Invoke-WinUtilInteractiveNerdFontInstall {
[CmdletBinding()]
param()
dynamicparam {
$url = 'https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/bin/scripts/lib/fonts.json'
$cacheFilePath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), 'winutil-nerd-fonts.json')
$cacheDuration = [TimeSpan]::FromMinutes(2)
function Get-FontsListFromWeb {
try {
$fonts = (Invoke-RestMethod -Uri $url -ErrorAction Stop -Verbose:$false -Debug:$false).fonts
$releaseUrl = "https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest"
foreach ($font in $fonts) {
$font.PSObject.Properties.Add([psnoteproperty]::new("releaseUrl", $releaseUrl))
}
return $fonts
}
catch {
$PSCmdlet.ThrowTerminatingError($_)
}
}
# Check if cache exists and is valid
$useCache = $false
if (Test-Path $cacheFilePath) {
$cacheAge = [DateTime]::Now - (Get-Item $cacheFilePath).LastWriteTime
if ($cacheAge -lt $cacheDuration) {
$useCache = $true
}
}
# Get fonts list either from cache or web
try {
if ($useCache) {
$fonts = Get-Content $cacheFilePath -Raw | ConvertFrom-Json
}
else {
$fonts = Get-FontsListFromWeb
$fonts | ConvertTo-Json -Depth 10 | Set-Content $cacheFilePath -Force
}
}
catch {
Write-Warning "Failed to get fonts list: $_"
return
}
# Create the runtime parameter dictionary
$RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
# Create the collection of attributes
$AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
# Create and set the parameters' attributes
$ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute
$ParameterAttribute.Mandatory = $false # Changed to false to allow interactive mode
$ParameterAttribute.Position = 0
# Add the attributes to the attributes collection
$AttributeCollection.Add($ParameterAttribute)
# Generate and set the ValidateSet
$ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($fonts.name)
$AttributeCollection.Add($ValidateSetAttribute)
# Create and return the dynamic parameter
$RuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter('FontName', [string], $AttributeCollection)
$RuntimeParameterDictionary.Add('FontName', $RuntimeParameter)
return $RuntimeParameterDictionary
}
begin {
$FontName = $PsBoundParameters['FontName']
$fontsPath = "$env:LOCALAPPDATA\Microsoft\Windows\Fonts"
# Create fonts directory if it doesn't exist
if (-not (Test-Path $fontsPath)) {
New-Item -Path $fontsPath -ItemType Directory -Force | Out-Null
}
# If no font name provided, show interactive menu
if (-not $FontName) {
Write-Host "`nAvailable Nerd Fonts:" -ForegroundColor Cyan
for ($i = 0; $i -lt $fonts.Count; $i++) {
Write-Host "$($i + 1). $($fonts[$i].name)"
}
do {
$selection = Read-Host "`nEnter the number of the font to install (or 'q' to quit)"
if ($selection -eq 'q') {
return
}
$index = [int]$selection - 1
if ($index -ge 0 -and $index -lt $fonts.Count) {
$FontName = $fonts[$index].name
break
}
else {
Write-Host "Invalid selection. Please try again." -ForegroundColor Red
}
} while ($true)
}
$selectedFont = $fonts | Where-Object { $_.name -eq $FontName }
}
process {
try {
Write-Host "`nInstalling $FontName..." -ForegroundColor Yellow
# Create temp directory
$tempDir = Join-Path $env:TEMP "WinUtilNerdFonts"
New-Item -Path $tempDir -ItemType Directory -Force | Out-Null
# Get latest release info
$latestRelease = Invoke-RestMethod -Uri $selectedFont.releaseUrl
$downloadUrl = $latestRelease.assets |
Where-Object { $_.name -like "*$($selectedFont.name)*" } |
Select-Object -ExpandProperty browser_download_url -First 1
if (-not $downloadUrl) {
Write-Error "Could not find download URL for $FontName"
return
}
# Download font
$zipPath = Join-Path $tempDir "$($selectedFont.name).zip"
Write-Host "Downloading from $downloadUrl..."
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath
# Extract and install fonts
Write-Host "Extracting and installing fonts..."
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
# Get all .ttf and .otf files
$fontFiles = Get-ChildItem -Path $tempDir -Recurse -Include "*.ttf","*.otf"
foreach ($fontFile in $fontFiles) {
$destination = Join-Path $fontsPath $fontFile.Name
Copy-Item -Path $fontFile.FullName -Destination $destination -Force
# Add font to registry
$fontRegistryPath = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
$fontRegistryName = "$($fontFile.BaseName) (TrueType)"
New-ItemProperty -Path $fontRegistryPath -Name $fontRegistryName -Value $fontFile.Name -PropertyType String -Force | Out-Null
}
Write-Host "Successfully installed $FontName!" -ForegroundColor Green
# Ask if user wants to install another font
$installMore = Read-Host "`nWould you like to install another font? (y/n)"
if ($installMore -eq 'y') {
Invoke-WinUtilInteractiveNerdFontInstall
}
}
catch {
Write-Error "Error installing font: $_"
Write-Host "Stack Trace: $($_.ScriptStackTrace)" -ForegroundColor Red
}
finally {
# Cleanup
if (Test-Path $tempDir) {
Remove-Item -Path $tempDir -Recurse -Force
}
}
}
}
Export-ModuleMember -Function Invoke-WinUtilInteractiveNerdFontInstall

View File

@ -38,6 +38,32 @@ function Invoke-WinUtilUninstallPSProfile {
if (-not $Fonts) { if (-not $Fonts) {
Write-Host "===> Successfully Uninstalled: Nerd Fonts. <===" -ForegroundColor Yellow Write-Host "===> Successfully Uninstalled: Nerd Fonts. <===" -ForegroundColor Yellow
} }
}
# Helper function used to uninstall a specific Nerd Fonts font corresponding registry keys.
function Uninstall-NerdFontRegKeys {
# Define the parameters block for the Uninstall-NerdFontsRegKey function.
param (
[string]$FontsRegPath = "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts",
[string]$FontFamilyName = "CaskaydiaCove"
)
try {
# Get all properties (font registrations) from the registry path
$registryProperties = Get-ItemProperty -Path $FontsRegPath
# Filter and remove properties that match the font family name
$registryProperties.PSObject.Properties |
Where-Object { $_.Name -match $FontFamilyName } |
ForEach-Object {
If ($_.Name -like "*$FontFamilyName*") {
Remove-ItemProperty -path $FontsRegPath -Name $_.Name -ErrorAction SilentlyContinue
}
}
} catch {
Write-Host "Error removing registry keys: $($_.exception.message)" -ForegroundColor Red
}
} }
# Check if Chris Titus Tech's PowerShell profile is currently available in the PowerShell profile folder. # Check if Chris Titus Tech's PowerShell profile is currently available in the PowerShell profile folder.
@ -87,11 +113,28 @@ function Invoke-WinUtilUninstallPSProfile {
# Call the function used to uninstall the specified Nerd Fonts package from the system. # Call the function used to uninstall the specified Nerd Fonts package from the system.
Uninstall-NerdFonts -FontsPath $FontsPath -FontFamilyName $FontFamilyName Uninstall-NerdFonts -FontsPath $FontsPath -FontFamilyName $FontFamilyName
} catch { } catch {
# Let the user know that an error was encountered when uninstalling Nerd Fonts. # Let the user know that an error was encountered when uninstalling Nerd Fonts.
Write-Host "Failed to uninstall Nerd Fonts. Error: $_" -ForegroundColor Red Write-Host "Failed to uninstall Nerd Fonts. Error: $_" -ForegroundColor Red
} }
# Attempt to uninstall the specified Nerd Fonts registry keys from the system.
try {
# Specify the registry path that the specified font registry keys will be uninstalled from.
[string]$FontsRegPath = "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
# Specify the name of the font registry keys that is to be uninstalled from the system.
[string]$FontFamilyName = "CaskaydiaCove"
# Call the function used to uninstall the specified Nerd Fonts registry keys from the system.
Uninstall-NerdFontRegKeys -FontsPath $FontsRegPath -FontFamilyName $FontFamilyName
} catch {
# Let the user know that an error was encountered when uninstalling Nerd Font registry keys.
Write-Host "Failed to uninstall Nerd Font Registry Keys. Error: $_" -ForegroundColor Red
}
# Attempt to uninstall the Terminal-Icons PowerShell module from the system. # Attempt to uninstall the Terminal-Icons PowerShell module from the system.
try { try {
# Get the content of the backup PowerShell profile and store it in-memory. # Get the content of the backup PowerShell profile and store it in-memory.
@ -185,3 +228,4 @@ function Invoke-WinUtilUninstallPSProfile {
} }
} }
} }

View File

@ -1,50 +0,0 @@
function Invoke-WinUtilpsProfile {
<#
.SYNOPSIS
Installs & applies the CTT Powershell Profile
#>
Invoke-WPFRunspace -Argumentlist $PROFILE -DebugPreference $DebugPreference -ScriptBlock {
param ( $psprofile)
function Invoke-PSSetup {
$url = "https://raw.githubusercontent.com/ChrisTitusTech/powershell-profile/main/Microsoft.PowerShell_profile.ps1"
$oldhash = Get-FileHash $psprofile -ErrorAction SilentlyContinue
Invoke-RestMethod $url -OutFile "$env:temp/Microsoft.PowerShell_profile.ps1"
$newhash = Get-FileHash "$env:temp/Microsoft.PowerShell_profile.ps1"
if ($newhash.Hash -ne $oldhash.Hash) {
write-host "===> Installing Profile.. <===" -ForegroundColor Yellow
# Starting new hidden shell process bc setup does not work in a runspace
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
Write-Host "Profile has been installed. Please restart your shell to reflect changes!" -ForegroundColor Magenta
write-host "===> Finished <===" -ForegroundColor Yellow
} else {
Write-Host "Profile is up to date" -ForegroundColor Green
}
}
if (Get-Command "pwsh" -ErrorAction SilentlyContinue) {
if ($PSVersionTable.PSVersion.Major -ge 7) {
Invoke-PSSetup
}
else {
write-host "Profile requires Powershell 7, which is currently installed but not used!" -ForegroundColor Red
# Load the necessary assembly for Windows Forms
Add-Type -AssemblyName System.Windows.Forms
# Display the Yes/No message box
$question = [System.Windows.Forms.MessageBox]::Show("Profile requires Powershell 7, which is currently installed but not used! Do you want to install Profile for Powershell 7?", "Question",
[System.Windows.Forms.MessageBoxButtons]::YesNo,
[System.Windows.Forms.MessageBoxIcon]::Question)
# Check the result
if ($question -eq [System.Windows.Forms.DialogResult]::Yes) {
Invoke-PSSetup
}
else {
Write-Host "Not proceeding with the profile setup!"
}
}
}
else {
write-host "Profile requires Powershell 7, which is not installed!" -ForegroundColor Red
}
}
}

View File

@ -47,7 +47,7 @@ function Set-WinUtilRegistry {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
} catch [System.Management.Automation.ItemNotFoundException] { } catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord Write-Warning $psitem.Exception.ErrorRecord
} catch [System.UnauthorizedAccessException]{ } catch [System.UnauthorizedAccessException] {
Write-Warning $psitem.Exception.Message Write-Warning $psitem.Exception.Message
} catch { } catch {
Write-Warning "Unable to set $Name due to unhandled exception" Write-Warning "Unable to set $Name due to unhandled exception"

View File

@ -46,7 +46,7 @@ function Invoke-WPFImpex {
if ($Config) { if ($Config) {
$jsonFile = Get-WinUtilCheckBoxes -unCheck $false | ConvertTo-Json $jsonFile = Get-WinUtilCheckBoxes -unCheck $false | ConvertTo-Json
$jsonFile | Out-File $Config -Force $jsonFile | Out-File $Config -Force
"iex ""& { `$(irm christitus.com/win) } -Config '$Config'""" | Set-Clipboard "iex ""& { `$(irm https://christitus.com/win) } -Config '$Config'""" | Set-Clipboard
} }
} catch { } catch {
Write-Error "An error occurred while exporting: $_" Write-Error "An error occurred while exporting: $_"