0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

新しいフォントが追加できるバッチファイル

Last updated at Posted at 2024-07-07

ダブルクリックすればフォントは追加できるけど

こんにちは。今回はダブルクリックすれば追加できるフォントについて
無駄にバッチファイルを作ったので共有します。

管理者として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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?