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?

More than 3 years have passed since last update.

Windowsユーザーのためのhosts書き換えショートカット

Last updated at Posted at 2021-12-13

DNSやロードバランサー、新しくサーバーの構築をすると私はよくhostsを書き換えて事前接続確認をしたりします。
ローカル環境の構築でもローカルのhostsを書き換えるというのはよくやります。

Windowsの場合hostsファイルはかなり深い場所にあるので、パスをたどるのに苦労する上、セキュリティ的に保護されているファイルなので、簡単には変更できません。

ということで変更のためのショートカットファイルを作成することで対応します。

新規ショートカットの作成で、パスを以下のように指定します。

%windir%\system32\notepad.exe "C:\Windows\System32\drivers\etc\hosts"

もちろんお気に入りのエディタがあればそれを指定します。
大抵のエディタは引数にファイルをとることができます。
私はVimが好きなので、Vimにしています。

作ったショートカットのプロパティを開き、管理者モードで実行するように設定するだけです。

qiita_20211214_01.png

あとは利便性を考えて、スタートメニューとかにショートカットを移動させておきましょう。
ユーザーのスタートメニューは以下になります。

%appdata%\Microsoft\Windows\Start Menu

qiita_20211214_02.png

するとスタートキーを押下後、hostsと入力するだけで、開けるようになります。

私の周りの人は毎回hostsファイルをたどって開いているので、もう少し楽な方法あるのになと思っています。

まぁhostsを書き換える人なんて、DNSの設定確認とか、ロードバランサーの設定確認とか、ローカル環境にバーチャルホストいっぱい立ててる人とか何でしょうが。。。

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?