How to use VSCode CLI to open the `hosts` file on Windows?



Tried code '%SystemRoot%\System32\drivers\etc\hosts' using Git Bash, but it fails to resolve %SystemRoot%, does anyone know how to achieve this?


It’s not clear what you are trying to do with VSCode CLI, but you can try using WINDIR environment variable, e.g. in MinGW (which is what Git Bash based on):

$ echo "$WINDIR/system32/drivers/etc/hosts"

Note that forward and backslashes are interchangeable in file names in Windows & MinGW-based tools.

Answered By – davlet

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More