-
Notifications
You must be signed in to change notification settings - Fork 0
/
Add-Fonts.ps1
37 lines (35 loc) · 890 Bytes
/
Add-Fonts.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$fontsFolder = "C:\Windows\Fonts\"
$FONTS = 0x14
$CopyOptions = 4 + 16;
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace($FONTS)
$allFonts = dir $fontsFolder
foreach($font in Get-ChildItem -Path $fontsFolder -File)
{
$dest = "C:\Windows\Fonts\$font"
echo "Nome da fonte $font"
try {
switch (($font -split "\.")[-1]) {
"TTF" {
$fn = "$(($font -split "\.")[0]) (TrueType)"
break
}
"OTF" {
$fn = "$(($font -split "\.")[0]) (OpenType)"
break
}
"TTC" {
$fn = "$(($font -split "\.")[0]) (TrueType)"
break
}
"FON" {
$fn = "$(($font -split "\.")[0]) (Raster)"
break
}
}
New-ItemProperty -Name $fn -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $font
}
catch {
write-warning $_.exception.message
}
}