mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
Added the script for adding fonts to the system by giving a source folder.
This commit is contained in:
41
docs/install-fonts.md
Normal file
41
docs/install-fonts.md
Normal file
@ -0,0 +1,41 @@
|
||||
The *install-fonts.ps1* Script
|
||||
===========================
|
||||
|
||||
install-fonts.ps1
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
$sourceFolder = "D:\related\FONT"
|
||||
|
||||
$fontsFolder = "$env:SystemRoot\Fonts"
|
||||
|
||||
$fontFiles = Get-ChildItem -Path $sourceFolder -Filter *.ttf
|
||||
|
||||
foreach ($font in $fontFiles) {
|
||||
$destination = "$fontsFolder\$($font.Name)"
|
||||
Copy-Item -Path $font.FullName -Destination $destination -Force
|
||||
|
||||
$fontName = [System.IO.Path]::GetFileNameWithoutExtension($font.Name)
|
||||
$fontRegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
|
||||
|
||||
$fontType = "TrueType"
|
||||
|
||||
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 19:36:33)*
|
Reference in New Issue
Block a user