ダブルクリックすればフォントは追加できるけど
こんにちは。今回はダブルクリックすれば追加できるフォントについて
無駄にバッチファイルを作ったので共有します。
管理者としてCMDを実行する必要があります
こちらがそのコードになります。ぜひ使ってみましょう
@echo off
setlocal enabledelayedexpansion
:: Set the path to the Windows Fonts folder
set "FONTS_FOLDER=%SystemRoot%\Fonts"
:: Prompt the user for the font file name
set /p "FONT_FILE=Enter the full path and name of the TTF font file: "
:: Check if the file exists
if not exist "%FONT_FILE%" (
echo Font file not found. Please check the path and try again.
goto :EOF
)
:: Extract the file name from the full path
for %%F in ("%FONT_FILE%") do set "FONT_NAME=%%~nxF"
:: Copy the font file to the Windows Fonts folder
copy "%FONT_FILE%" "%FONTS_FOLDER%"
if errorlevel 1 (
echo Failed to copy the font file. Make sure you have administrator privileges.
goto :EOF
)
:: Register the font
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "%FONT_NAME% (TrueType)" /t REG_SZ /d "%FONT_NAME%" /f
:: Notify the user
echo Font "%FONT_NAME%" has been successfully added and registered.
:: Prompt to restart applications
echo Please restart any open applications to use the new font.
endlocal