Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active January 14, 2025 18:07
Show Gist options
  • Save guitarrapc/a6e90edf8e70726f40e0ef309285fb70 to your computer and use it in GitHub Desktop.
Save guitarrapc/a6e90edf8e70726f40e0ef309285fb70 to your computer and use it in GitHub Desktop.
Remove "Open with Visual Studio" in the Windows Explorer Context menu

Summy

There are 2 registry keys you need to remove.

  • HKEY_CLASSES_ROOT\Directory\Background\shell\AnyCode
  • HKEY_CLASSES_ROOT\Directory\shell\AnyCode

Steps

Step1. Check you value before deletetion

$ Get-Item "registry::HKEY_CLASSES_ROOT\Directory\Background\shell\AnyCode"

    Hive: HKEY_CLASSES_ROOT\Directory\Background\shell

Name                           Property
----                           --------
AnyCode                        (default) : @C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\1033\VSLauncherUI.dll,-1002
                               Icon      : C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe,-105
$ Get-Item "registry::HKEY_CLASSES_ROOT\Directory\shell\AnyCode"

    Hive: HKEY_CLASSES_ROOT\Directory\shell

Name                           Property
----                           --------
AnyCode                        (default) : @C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\1033\VSLauncherUI.dll,-1002
                               Icon      : C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe,-105

Step2. Remove Keys

$keys = @("Directory\shell", "Directory\Background\shell")
foreach ($key in $keys) {
  $reg = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey($key, $true)
  if ($null -ne $reg) {
    $reg.DeleteSubKeyTree("AnyCode", $true)
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment