使用批处理脚本编辑注册表文件

时间:2015-12-04 22:08:18

标签: batch-file scripting registry

我想进行以下注册表更改:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI]
"LogPixels"=dword:00000060

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0000\Software\Fonts]
"LogPixels"=dword:00000060

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0001\Software\Fonts]
"LogPixels"=dword:00000060

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current\Software\Fonts]
"LogPixels"=dword:00000060

[-HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\FontDPI]

[HKEY_CURRENT_USER\Control Panel\Desktop]
"LogPixels"=dword:00000060

但我希望它们是通过批处理脚本制作的。我该怎么做呢?我试图将这个全部保存为.reg文件,只是使用我的脚本导入文件,但是我收到一个错误,它无法打开文件。

1 个答案:

答案 0 :(得分:0)

我找到了一种方法来使用reg add来获得我需要的东西:

::Restore DPI to 100% (CDB Text Scaling Issue Fix)
::Call "%~dp0\Restore 100% DPI Fix.bat" (Doesn't seem to be working right)
@Echo OFF
cls

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI" /v "LogPixels" /t REG_DWORD /d "00000060" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0000\Software\Fonts" /v "LogPixels" /t REG_DWORD /d "00000060" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\0001\Software\Fonts" /v "LogPixels" /t REG_DWORD /d "00000060" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\Current\Software\Fonts" /v "LogPixels" /t REG_DWORD /d "00000060" /f
reg DELETE "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\FontDPI" /f
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v "LogPixels" /t REG_DWORD /d "00000060" /f