Skip to content

Instantly share code, notes, and snippets.

@ThomazPom
Created October 3, 2024 16:58
Show Gist options
  • Save ThomazPom/ffa0c747fa1fd2b9dee26ebcd9738380 to your computer and use it in GitHub Desktop.
Save ThomazPom/ffa0c747fa1fd2b9dee26ebcd9738380 to your computer and use it in GitHub Desktop.

Windows Registry Editor Script Explanation

Overview

This script customizes the right-click context menu in Windows Explorer to add options for opening PowerShell at specific locations. It creates two context menu entries, one for the background of a directory and another for the directory itself, allowing easy access to PowerShell from those locations.

Key Functionalities:

  1. Context Menu for Directory Background:

    • Adds an option called "Open Powershell" when right-clicking on the background of a folder (the empty space within a folder in Explorer).
    • When selected, it opens PowerShell with the current folder as the active directory.
  2. Context Menu for Directory Itself:

    • Adds an option called "Open in Powershell" when right-clicking on a folder.
    • When selected, it opens PowerShell directly in the clicked folder.

Other Attributes:

  • Icon:

    • Both entries display the PowerShell icon.
  • No Working Directory:

    • Specifies that PowerShell should open without considering any previous working directory.
  • ShowBasedOnVelocityId:

    • This value controls when and where the context menu items are shown, using a system velocity ID to control visibility.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\directory\background\shell\ps1]
@="Open Powershell"
"Icon"="powershell.exe"
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\directory\background\shell\ps1\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\directory\shell\ps1]
@="Open in powershell"
"Icon"="powershell.exe"
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
[HKEY_CLASSES_ROOT\directory\shell\ps1\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment