-
Command execution: You Windows users should open command prompt in admin mode and run the commands mentioned here without the
sudo
part. -
Privacy Concerns: It is well known that Microsoft collects your data even if you don't use VSCode.
-
Recommendation: Like every other Linux user, I am suggesting you to switch to Linux, for enhanced privacy.
-
Alternative Option: However if it is impossible at the moment, like if you are in a school computer,
- Watch this video,
- and Visit this link
to stop the data collection (not a foolproof way but works to some extent). I have visited and tested what is said in the links myself and it works fine. I recommend you too try doing it and test it with Wireshark if you want to.
-
Host file location: Your hosts file is at
C:\Windows\System32\drivers\etc\hosts
-
Error Handling: If Python throws errors while trying to open your hosts file, or if you are unable to open it manually and you are not even able to do it even after taking full ownership,
- Copy the file
C:\Windows\System32\drivers\etc\hosts.backup
to your desktop. - Rename it to
hosts
- Follow the guides linked above and update the file in your desktop accordingly
- Delete the original host file
- Copy the file in your desktop to the original location. Now you will be able to update it or edit it.
- Copy the file
-
Note: You can't stop it 100% because Windows is proprietary spyware and that's why you should switch to Linux.
This script is for those
- Who care about Microsoft collecting your data through VS Code telemetry without consent | Archived
- Can't use VSCodium because you have to use propertiary extensions / features like sync and etc
- And don't want Microsoft to collect your data while you are not using the features
- Open up vscode-privacy.py and edit
SETTINGS_DOT_JSON
andHOSTS_FILE
to their respective paths in your computer - (Optional) To create a copy of hosts file and settings.json file without changing anything, run
sudo python3 vscode-privacy.py
- To increase privacy, run
sudo python3 vscode-privacy.py --increase-privacy
- To decrease privacy, run
sudo python3 vscode-privacy.py --decrease-privacy
- (Optional) To wipe out the copies of hosts file and settings.json file, run
sudo python3 vscode-privacy.py --wipe
When this script "increases" your privacy, it appends few lines to host file and
edits some settings in vscode's settings.json. They can be found in hosts_increase_privacy
and settings_increase_privacy.json
respectively. Alternatively, when this script "decreases" your privacy, it reverts
back to what they were before you ran this script.
The few lines appended to hosts file block the vscode domains by redirecting them to localhost. And the settings edit turns off all telemetry possible. So if you want to sign in to enable sync, or install any extensions, or use any extensions that require connecting those services, make sure you aren't already blocing those domains (settings.json is not a problem initially) run
sudo python3 vscode-privacy.py --decrease-privacy
and do what you want to do.
After your job of connecting VSCode to the internet is done, run
sudo python3 vscode-privacy.py --increase-privacy
This script is for automating the process of editing host file and settings file for those who constantly need to run services that cost your privacy in vscode.
- Python 3.x (I used 3.11.2 while writing this script)