Home > Mac administration, macOS, Scripting > Disabling telemetry for Microsoft’s Visual Studio Code

Disabling telemetry for Microsoft’s Visual Studio Code

Recently, I was tasked with figuring out how to disable telemetry for Microsoft’s Visual Studio Code. Normally, you can disable telemetry in a Microsoft application through using a macOS configuration profile or by using a defaults command. In this case though, Microsoft bought Visual Studio Code along with the rest of Xamarin, and Xamarin had some different ideas on where and how to store settings.

In the case of Visual Studio Code, the command to disable telemetry is stored as a .json file in the following location:

/Users/username_here/Library/Application Support/Code/User/settings.json

Screen Shot 2020 03 20 at 12 56 55 PM

After some research and some work with an open source tool named jq, I was able to figure out how to handle disabling the telemetry setting. For more details, please see below the jump.

The method I arrived at uses jq. This is a JSON manipulation tool which is not included with macOS, so I needed to install it separately before using it.

Once I had jq installed, I was able to write a script which did the following:

1. Checked to make sure the Mac in question was logged-in
2. Verified that the logged-in user was not the root user.
3. Verified that jq was installed at a location defined in the script and set as executable.
4. Checked for the existence of the settings.json file in /Users/username_here/Library/Application Support/Code/User.

If /Users/username_here/Library/Application Support/Code/User/settings.json is present, the script does the following:

A. Reads out the contents of the existing settings.json file.
B. Adds the following setting to the copied contents:

“telemetry.enableTelemetry”: false

C. Overwrites the existing settings.json file with the copied contents, which added the new telemetry setting.
D. Changes the ownership of the /Users/username_here/Library/Application Support/Code/User/settings.json file to that of the logged-in user.

If /Users/username_here/Library/Application Support/Code/User/settings.json is not present, the script does the following:

A. Creates the settings.json file in /Users/username_here/Library/Application Support/Code/User.
B. Adds the following setting to the newly-created file:

“telemetry.enableTelemetry”: false

C. Changes the ownership of the /Users/username_here/Library/Application Support/Code/User/settings.json file to that of the logged-in user.

5. Verifies that the telemetry.enableTelemetry setting is present and set to false.

The script is available below. It is also available from the following location on GitHub:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/disable_visual_studio_code_telemetry

  1. Ted Jangius
    March 20, 2020 at 7:11 pm

    One can use VSCodium which is a direct fork of VS Code with the telemetry and privacy invading aspects removed.
    See https://vscodium.com/

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: