Instantly share code, notes, and snippets.
Last active
September 23, 2025 13:19
-
Star
2
(2)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
-
Save attilatorda/c89ed4fbb4953e7d55ed5236abb0dcba to your computer and use it in GitHub Desktop.
Windows Explorer Right-Click Tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| SETLOCAL EnableDelayedExpansion | |
| :: Check if running as admin (required for registry edits) | |
| net session >nul 2>&1 | |
| if %errorLevel% neq 0 ( | |
| echo This script requires administrator privileges. | |
| echo Please right-click and "Run as administrator". | |
| pause | |
| exit /b | |
| ) | |
| :: 1. Add "Open Command Prompt Here" | |
| reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere" /ve /d "Open Command Prompt Here" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command" /ve /d "cmd.exe /s /k pushd \"%%V\"" /f | |
| :: 2. Add "Open Command Prompt Here (Admin)" | |
| reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAdmin" /ve /d "Open Command Prompt Here (Admin)" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHereAdmin\command" /ve /d "powershell -command \"Start-Process cmd -Verb runAs -ArgumentList '/s /k pushd \"%%V\"'\"" /f | |
| :: 3. Add "Open PowerShell Here" | |
| reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\OpenPowerShellHere" /ve /d "Open PowerShell Here" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\OpenPowerShellHere\command" /ve /d "powershell -NoExit -Command \"Set-Location -LiteralPath '%%V'\"" /f | |
| :: 4. Add "Open PowerShell Here (Admin)" | |
| reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\OpenPowerShellHereAdmin" /ve /d "Open PowerShell Here (Admin)" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\Background\shell\OpenPowerShellHereAdmin\command" /ve /d "powershell -Command \"Start-Process powershell -Verb RunAs -ArgumentList '-NoExit', '-Command', 'Set-Location -LiteralPath ''%%V'''\"" /f | |
| :: 5. Add "Add to System PATH" | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\AddToPath" /ve /d "Add to System PATH" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\AddToPath\command" /ve /d "cmd.exe /c \"setx PATH \"%%PATH%%;%%1\" /m\" && pause" /f | |
| :: 6. Add "Check PATH locations" - NEW FEATURE | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\CheckPath" /ve /d "Check PATH locations" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\CheckPath\command" /ve /d "cmd.exe /c \"echo Checking PATH for: %%1 && echo. && for %%p in (%PATH%) do (echo %%p | find /i \"%%~1\" >nul && echo [FOUND] %%p)\" && echo. && pause" /f | |
| :: 7. Add "Copy Folder Path" - NEW FEATURE | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\CopyFolderPath" /ve /d "Copy Folder Path" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\CopyFolderPath\command" /ve /d "cmd.exe /c \"echo %%1| clip\" && exit" /f | |
| :: 8. Add "Take Ownership" - NEW FEATURE | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership" /ve /d "Take Ownership" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\TakeOwnership\command" /ve /d "cmd.exe /c \"takeown /f \"%%1\" /r /d y && icacls \"%%1\" /grant administrators:F /t\" && pause" /f | |
| :: 9. Add "Empty Folder Cleaner" - NEW FEATURE | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\EmptyFolderCleaner" /ve /d "Find Empty Folders" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\EmptyFolderCleaner\command" /ve /d "cmd.exe /c \"echo Searching for empty folders in: %%1 && echo. && powershell -command \"Get-ChildItem -Path '%%1' -Recurse -Directory | Where-Object {!(Get-ChildItem -Path $_.FullName -Recurse -Force)} | ForEach-Object {Write-Host 'Empty folder:' $_.FullName}\" && echo. && pause" /f | |
| :: 10. Add "Duplicate File Finder" (basic) - NEW FEATURE | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\DuplicateFinder" /ve /d "Find Duplicate Files" /f | |
| reg add "HKEY_CLASSES_ROOT\Directory\shell\DuplicateFinder\command" /ve /d "cmd.exe /c \"echo Finding duplicate files in: %%1 && echo. && powershell -command \"Get-ChildItem -Path '%%1' -Recurse -File | Group-Object Length | Where-Object Count -gt 1 | ForEach-Object {Write-Host 'Potential duplicates (Size:' $_.Name 'bytes):'; $_.Group.FullName; echo.}\" && pause" /f | |
| echo. | |
| echo ======================================== | |
| echo Successfully added all context menu options! | |
| echo. | |
| echo NEW FEATURES ADDED: | |
| echo - Check PATH locations | |
| echo - Copy Folder Path | |
| echo - Take Ownership | |
| echo - Empty Folder Cleaner | |
| echo - Duplicate File Finder | |
| echo. | |
| echo Restart File Explorer or log off/on for changes to fully apply. | |
| echo ======================================== | |
| pause |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :: Optional: Create uninstaller script | |
| ( | |
| echo @echo off | |
| echo SETLOCAL EnableDelayedExpansion | |
| echo. | |
| echo net session ^>nul 2^>^&1 | |
| echo if %%errorLevel%% neq 0 ( | |
| echo echo This script requires administrator privileges. | |
| echo echo Please right-click and "Run as administrator". | |
| echo pause | |
| echo exit /b | |
| echo ) | |
| echo. | |
| echo echo Removing context menu options... | |
| echo. | |
| for %%x in (OpenCmdHere OpenCmdHereAdmin OpenPowerShellHere OpenPowerShellHereAdmin AddToPath CheckPath CopyFolderPath VSCode TakeOwnership FolderSize EmptyFolderCleaner DuplicateFinder) do ( | |
| echo reg delete "HKEY_CLASSES_ROOT\Directory\shell\%%x" /f 2^>nul | |
| echo reg delete "HKEY_CLASSES_ROOT\Directory\Background\shell\%%x" /f 2^>nul | |
| ) | |
| echo. | |
| echo echo Context menu options removed! | |
| echo pause | |
| ) > "RemoveContextMenuOptions.bat" | |
| echo Uninstaller script created: RemoveContextMenuOptions.bat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment