Change Default Application For File Type Via Command Line

While I was setting up Windows Terminal, I found that trying to modify settings would open a new instance of Visual Studio since that was my system’s default application for .json files. That’s a pretty heavy choice for what amounts to a text editor, so I thought I’d change my default app to Visual Studio Code. Should be easy, right?

The usual way to do this is through Windows Settings:

Settings > Default Apps > Choose default apps by file type

The problem is, when I did that, Visual Studio Code wasn’t an option!

That’s okay, though. We can change the default app through the command prompt. Open a command prompt in Windows Terminal (note: Command Prompt, not PowerShell) and run the following:

assoc .json=jsonfile
ftype jsonfile="%AppData%\Local\Programs\Microsoft VS Code\Code.exe" "%1" %*

Solution credit, here.

Author: Adam Prescott

I'm enthusiastic and passionate about creating intuitive, great-looking software. I strive to find the simplest solutions to complex problems, and I embrace agile principles and test-driven development.

Leave a comment

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