Merge pull request #27 from Arash-Seifi/main

Add script to install fonts and update registry
This commit is contained in:
Markus Fleschutz 2025-01-29 17:44:13 +01:00 committed by GitHub
commit a2061269ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 87 additions and 0 deletions

View File

@ -203,6 +203,7 @@ Mega Collection of PowerShell Scripts
| [get-sha1.ps1](scripts/get-sha1.ps1) | Prints the SHA1 checksum of the given file. [Read more...](docs/get-sha1.md) |
| [get-sha256.ps1](scripts/get-sha256.ps1) | Prints the SHA256 checksum of the given file. [Read more...](docs/get-sha256.md) |
| [inspect-exe.ps1](scripts/inspect-exe.ps1) | Prints basic information of the given executable file. [Read more...](docs/inspect-exe.md) |
| [install-fonts.ps1](scripts/install-fonts.ps1) | installs fonts and updates the registry. [Read more...](docs/install-fonts.md) |
| [list-dir-tree.ps1](scripts/list-dir-tree.ps1) | Lists the directory tree content. [Read more...](docs/list-dir-treep.md) |
| [list-empty-dirs.ps1](scripts/list-empty-dirs.ps1) | Lists empty subfolders within the given directory tree. [Read more...](docs/list-empty-dirs.md) |
| [list-empty-files.ps1](scripts/list-empty-files.ps1) | Lists empty files within the given directory tree. [Read more...](docs/list-empty-files.md) |

54
docs/install-fonts.md Normal file
View File

@ -0,0 +1,54 @@
The *install-fonts.ps1* Script
===========================
install-fonts.ps1 [[-sourceFolder] <string>]
Parameters
----------
```powershell
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
Script Content
--------------
```powershell
param(
[string]$sourceFolder = ""
)
# If no parameter is given, prompt the user for the source folder
if (-not $sourceFolder) {
$sourceFolder = Read-Host "Please enter the path to the source folder"
}
# Set the destination folder for fonts, you don't need to change this
$fontsFolder = "$env:SystemRoot\Fonts"
# Get all font files from the source folder
$fontFiles = Get-ChildItem -Path $sourceFolder -Filter *.ttf
foreach ($font in $fontFiles) {
# Copy font files to the Fonts folder
$destination = "$fontsFolder\$($font.Name)"
Copy-Item -Path $font.FullName -Destination $destination -Force
# Add font to registry
$fontName = [System.IO.Path]::GetFileNameWithoutExtension($font.Name)
$fontRegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
# For TrueType fonts
$fontType = "TrueType"
# Add the registry entry
New-ItemProperty -Path $fontRegistryPath -Name "$fontName ($fontType)" -PropertyType String -Value $font.Name -Force
}
Write-Output "Fonts have been installed successfully."
```
*(page generated by convert-ps2md.ps1 as of 01/29/2025 20:04:23)*

32
scripts/install-fonts.ps1 Normal file
View File

@ -0,0 +1,32 @@
param(
[string]$sourceFolder = ""
)
# If no parameter is given, prompt the user for the source folder
if (-not $sourceFolder) {
$sourceFolder = Read-Host "Please enter the path to the source folder"
}
# Set the destination folder for fonts, you don't need to change this
$fontsFolder = "$env:SystemRoot\Fonts"
# Get all font files from the source folder
$fontFiles = Get-ChildItem -Path $sourceFolder -Filter *.ttf
foreach ($font in $fontFiles) {
# Copy font files to the Fonts folder
$destination = "$fontsFolder\$($font.Name)"
Copy-Item -Path $font.FullName -Destination $destination -Force
# Add font to registry
$fontName = [System.IO.Path]::GetFileNameWithoutExtension($font.Name)
$fontRegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
# For TrueType fonts
$fontType = "TrueType"
# Add the registry entry
New-ItemProperty -Path $fontRegistryPath -Name "$fontName ($fontType)" -PropertyType String -Value $font.Name -Force
}
Write-Output "Fonts have been installed successfully."