How to use VSCode CLI to open the `hosts` file on Windows?
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" C:\WINDOWS/system32/drivers/etc/hosts
Note that forward and backslashes are interchangeable in file names in Windows & MinGW-based tools.
Answered By – davlet