本帖最后由 小白龙 于 2023-5-29 18:56 编辑
回复 2# idwma
没有, 我在CMD下, 用 dir *mn* 能看到拷贝的文件在Font文件夹里面了,
最后那条命令的意思是,既然已经拷贝到Font文件夹了, 那原字体文件就没什么用了, 就把它删除, 但是死活执行不成功, 字体也没有安装上, 在别的软件下找不到安装的字体, 真是怪了 | < | | cls&echo off&cd /d "%~dp0"&mode con lines=5000&rem bat保存为ANSI/GB2312编码 | | set "current=%cd%" | | set "nm=%~n0.bat" | | powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression" | | pause | | exit | | | | | | | | $fontFilePath = "$env:current\A.ttf" | | $fontFilePath | | | | | | Add-Type -AssemblyName System.Drawing | | $fontCollection = New-Object System.Drawing.Text.PrivateFontCollection | | $fontCollection.AddFontFile($fontFilePath) | | $fontName = $fontCollection.Families[0].Name | | $fontName | | | | | | $fontInstalled = $false | | $installedFontCollection = New-Object System.Drawing.Text.InstalledFontCollection | | $installedFontFamilies = $installedFontCollection.Families | | foreach ($fontFamily in $installedFontFamilies) | | { | | if ($fontFamily.Name -eq $fontName) | | { | | $fontInstalled = $true | | break | | } | | } | | $fontInstalled | | | | | | if (!$fontInstalled) | | { | | | | $destinationFolderPath = "C:\Windows\Fonts" | | Copy-Item -Path $fontFilePath -Destination $destinationFolderPath -Force | | | | | | Add-Type -TypeDefinition @' | | using System; | | using System.Runtime.InteropServices; | | | | public static class FontInstaller | | { | | [DllImport("gdi32.dll")] | | private static extern int AddFontResource(string lpFileName); | | | | public static int Install(string fontFilePath) | | { | | return AddFontResource(fontFilePath); | | } | | } | | '@ | | [FontInstaller]::Install("C:\Windows\Fonts\A.ttf") | | | | | | del $fontFilePath -Force | | }COPY |
|