3
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 2020-08-26

ローカル環境でhostsファイルを書き換えてテストしたいことがあるかと思います。
実際のパスはここC:\Windows\System32\drivers\etc\hostsですが、
いちいち覚えるのも面倒だし、エディタで開こうとすると権限どうのこうので面倒だと思います。

そんな時、コマンドプロンプトファイル名を指定して実行にこれを打ち込んでください。
管理者権限でメモ帳を立ち上げます。

powershell -NoProfile -ExecutionPolicy unrestricted -Command "start notepad C:\Windows\System32\drivers\etc\hosts -verb runas"

便利ですね。

notepadの部分がメモ帳の起動コマンドとなりますので、VSCodeを立ち上げたいときはここをcodeに変更してください。
また、新しいクロスプラットフォームのPowerShell Coreを使っていらっしゃる方は、powershellの部分をpwshに変えていただければと思います。

便利ですね。

3
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
3
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?