如何阻止MacBook上下载的Batch文件自动关联为Visual Studio Code文档
Fixing .bat File Default Association with VS Code on MacBook
Got it, let's sort out this annoying auto-association issue for your batch files. Here are three straightforward methods to stop VS Code from automatically claiming .bat files as its own:
Method 1: Use Finder's Get Info Panel (Graphical Approach)
This is the easiest way if you prefer clicking around over terminal commands:
- Locate any .bat file on your Mac, right-click (or Control-click) it, and select Get Info from the menu.
- In the window that pops up, scroll down to the Open with section. Click the dropdown menu and select the program you want to use by default (e.g., TextEdit, or another text editor of your choice). If you don't see your preferred app, click Other to browse for it—make sure to check the Always Open With box at the bottom of the file picker if needed.
- Once you've selected the right app, click the Change All... button just below the dropdown. Confirm the prompt that appears, and all .bat files on your Mac will now open with your chosen app instead of VS Code.
Method 2: Terminal Command (For Power Users)
If you're comfortable with the command line, you can directly modify macOS's Launch Services (which handles file associations) or use a dedicated tool:
Option A: Use duti (Recommended)
- First, install
dutivia Homebrew (a common macOS package manager):brew install duti - Run this command to set TextEdit as the default for .bat files (replace
com.apple.TextEditwith your app's bundle ID if you want a different program):duti -s com.apple.TextEdit .bat all
Option B: Use Built-in lsregister
If you don't want to install anything, use macOS's built-in tool:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -v -f -c com.apple.TextEdit -u .bat
This will update the association to use TextEdit for all .bat files.
Method 3: Adjust VS Code's Internal Settings
Sometimes VS Code automatically grabs associations for file types it doesn't recognize. Let's turn that off:
- Open VS Code and press
Command + ,to open Settings. - In the search bar at the top, type
files.associations. - Look for any entry where the key is
.batand the value is something likebatorvscode.bat. If you see it, click the trash icon next to that line to remove the association. - Save the settings (VS Code usually auto-saves), and it will no longer automatically claim .bat files.
内容的提问来源于stack exchange,提问作者chris
相关产品推荐
相关产品推荐

