Skip to content

Instantly share code, notes, and snippets.

@nidefawl
Created February 13, 2022 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nidefawl/65af35899c657bee6f68b5c90e1a9333 to your computer and use it in GitHub Desktop.
Save nidefawl/65af35899c657bee6f68b5c90e1a9333 to your computer and use it in GitHub Desktop.
VSCode Insiders Shell handlers
#!/usr/bin/env python3
# Register the shell handlers (open folder/file with) for a vscode insiders installation
import winreg as reg
installLocation = 'C:\\dev\\vscode-insiders'
vscodeExe = f'{installLocation}\\Code - Insiders.exe'
vscodeIcon = f'{installLocation}\\resources\\app\\resources\\win32\\default.ico'
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\*\shell\VSCode-Insiders")
reg.SetValueEx(handle, "", 0, reg.REG_SZ, "Open with C&ode-Insiders")
reg.SetValueEx(handle, "Icon", 0, reg.REG_EXPAND_SZ, vscodeExe)
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\*\shell\VSCode-Insiders\command")
reg.SetValueEx(handle, "", 0, reg.REG_EXPAND_SZ, f"\"{vscodeExe}\" \"%1\"")
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Directory\shell\VSCode-Insiders")
reg.SetValueEx(handle, "", 0, reg.REG_SZ, "Open with C&ode-Insiders")
reg.SetValueEx(handle, "Icon", 0, reg.REG_EXPAND_SZ, vscodeExe)
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Directory\shell\VSCode-Insiders\command")
reg.SetValueEx(handle, "", 0, reg.REG_EXPAND_SZ, f"\"{vscodeExe}\" \"%V\"")
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Directory\Background\shell\VSCode-Insiders")
reg.SetValueEx(handle, "", 0, reg.REG_SZ, "Open with C&ode-Insiders")
reg.SetValueEx(handle, "Icon", 0, reg.REG_EXPAND_SZ, vscodeExe)
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Directory\Background\shell\VSCode-Insiders\command")
reg.SetValueEx(handle, "", 0, reg.REG_EXPAND_SZ, f"\"{vscodeExe}\" \"%V\"")
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Drive\shell\VSCode-Insiders")
reg.SetValueEx(handle, "", 0, reg.REG_SZ, "Open with C&ode-Insiders")
reg.SetValueEx(handle, "Icon", 0, reg.REG_EXPAND_SZ, vscodeExe)
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Drive\shell\VSCode-Insiders\command")
reg.SetValueEx(handle, "", 0, reg.REG_EXPAND_SZ, f"\"{vscodeExe}\" \"%V\"")
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Applications\Code - Insiders.exe\shell\open")
reg.SetValueEx(handle, "Icon", 0, reg.REG_EXPAND_SZ, vscodeExe)
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Applications\Code - Insiders.exe\shell\open\command")
reg.SetValueEx(handle, "", 0, reg.REG_EXPAND_SZ, f"\"{vscodeExe}\" \"%1\"")
reg.CloseKey(handle)
handle = reg.CreateKey(reg.HKEY_CURRENT_USER, "SOFTWARE\Classes\Applications\Code - Insiders.exe\DefaultIcon")
reg.SetValueEx(handle, "", 0, reg.REG_EXPAND_SZ, vscodeIcon)
reg.CloseKey(handle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment