D.

reg.exe を利用してスクリプトで Windows の環境を変更する。

reg.exe を使えばレジストリをコマンドで変更できる。これを利用するスクリプトを書けば、コントロールパネルなどのダイアログを呼び出さなくても Windows の環境を切り替えることができる。


ThinkPad のブラウザキーの有効/無効を切り替えるスクリプトを書いた。

@echo off

set REGKey=HKLM¥SYSTEM¥CurrentControlSet¥Control¥Keyboard Layout
set REGValue="Scancode Map"

set RemoteMachine=%1

if ""=="%1" goto Usage
if "/?"=="%1" goto Usage
if /I "/h"=="%1" goto Usage
if /I "/a"=="%1" goto LocalMachine
if /I "/d"=="%1" goto LocalMachine
if /I "/b"=="%1" goto LocalMachine
set RemoteMachineName=%1
set Action=%2

:Parse
if /I "/a" == "%Action%" goto Add
if /I "/d" == "%Action%" goto Delete
if /I "/b" == "%Action%" goto Browse
goto Usage

:Add
rem レジストリを追加する
echo - レジストリキーを追加します - 操作対象は%RemoteMachineName%
REG ADD "¥¥%RemoteMachine%¥%REGKey%" /v %REGValue% /t REG_BINARY /d 00000000000000000300000000006ae0000069e000000000 /f
echo.
goto End

:Delete
rem レジストリを削除する
echo - レジストリキーを削除します - 操作対象は%RemoteMachineName%
REG DELETE "¥¥%RemoteMachine%¥%REGKey%" /v %REGValue% /f
echo.
goto End

:Browse
rem 操作対象のレジストリを表示する
echo - レジストリ値を表示 - 操作対象は%RemoteMachineName%
REG QUERY "¥¥%RemoteMachine%¥%REGKey%"
goto End

:LocalMachine
set Action=%1
set RemoteMachine=.
set RemoteMachineName=localhost
goto Parse

:Usage
rem コマンドラインのオプション
echo ------------------------------------------------------------
echo Usage:
echo %0 [machine_name] [/a] [/d] [/b] [/h]
echo /a = Add Registry
echo /d = Delete Registry
echo /b = Browse Registry
echo /h = Help
echo.
echo Examples:
echo %0 mymachine /a (Add Registry on machine "mymachine")
echo %0 /d (Delete Registry on the local machine)
echo ------------------------------------------------------------

:End
rem 終了時に環境変数をクリア
set REGKey=
set REGValue=
set Action=
set RemoteMachine=
set RemoteMachineName=

この例では、スクリプト名にオプション /a を付ければブラウザキーが無効になる。有効に戻すには /d オプションを付けてスクリプトを実行すればいい。

参考

ThinkPad X40 -ブラウザ・キーの無効化-
http://cherry.usacho.jp/20040320.html