開發筆記 | Aiden Lin 林瑋杰

Back

問題#

在某一次的 vscode 版本更新後,我發現 windows 的右鍵選單中原本的 以 Visual Studio Code 開啟 選項不見了。這邊再透過 reg 的方式將選單註冊回來。

解決方法#

  1. 在任意位置先建立起一個 vscode.txt 檔案

  2. 並將下列的程式碼複製貼上

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="以 Visual Studio Code 開啟"
"Icon"="C:\\Program Files\\Microsoft VS Code\\Code.exe,0"

[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@="以 Visual Studio Code 開啟資料夾"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\",0"

[HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
@="以 Visual Studio Code 開啟資料夾"
"Icon"="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\",0"

[HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
@="\"C:\\Program Files\\Microsoft VS Code\\Code.exe\" \"%V\""
reg

當中有一個 Vscode 程式的路徑需要以你實際安裝的路徑為主,要記得將路徑中的 \ 變成 \\

常見的安裝目錄有兩個位置

  • C:\Program Files\Microsoft VS Code\Code.exe
  • C:\Users<YourUserName>\AppData\Local\Programs\Microsoft VS Code\Code.exe

也可以使用終端機的指令來確認

where code
bash

終端機指令查詢 vscode 位置

  1. vscode.txt 檔案的副檔名改成 .reg,例如 vscode.reg,直接右鍵選擇合併即可

這時候就可以在右鍵選單中看到 以 Visual Studio Code 開啟 的選項了。

Comment seems to stuck. Try to refresh?✨