├── LICENSE ├── Readme.md ├── cursorOpenFolder.bat ├── image.png ├── install-open-with-cursor.ps1 └── uninstall-open-with-cursor.ps1 /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Maciej Pulikowski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 |
9 | 10 | --- 11 | 12 | 13 | 14 | 15 | # 🖱️ Open with Cursor in Context Menu 16 | 17 | This project provides PowerShell scripts to add and remove "Open with Cursor" options to the Windows context menu for files, folders, and background areas. 18 | 19 |  20 | 21 | 22 | ## ✨ Features 23 | 24 | - Adds "Open with Cursor" option to: 25 | - File context menu 📄 26 | - Folder context menu 📁 27 | - Background context menu (when right-clicking in an empty area of a folder) 🖼️ 28 | - Removes these context menu entries with uninstalling script 🗑️ 29 | 30 | 31 | ## 🚀 Installation 32 | 33 | 1. Download the `install-open-with-cursor.ps1` script from https://github.com/Puliczek/open-with-cursor-context-menu/raw/main/install-open-with-cursor.ps1 34 | 2. Right-click on the downloaded script and select "Run with PowerShell". 35 | 3. If prompted, allow the script to run with administrator privileges. 36 | 37 | The script will automatically add the "Open with Cursor" options to your context menus. ✅ 38 | 39 | Or choose cursorOpenFolder.bat (Thanks to @eatcosmos) (.reg method) 40 | 41 | 42 | ## 🔧 Troubleshooting 43 | 44 | If you see following tips: can not load ...., seee about_Execution_Policies 45 | 46 | You need to run command like 47 | 48 | ```bash 49 | Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser 50 | ``` 51 | 52 | It will allow you run ps1 scripts from github, after done, please run following command to reset it 53 | 54 | ```bash 55 | 56 | Set-ExecutionPolicy -ExecutionPolicy Default -Scope CurrentUser 57 | ``` 58 | 59 | If the context menu options don't appear immediately after running the installation script: 60 | 61 | Restart Windows Explorer using Terminal: 62 | 63 | - Press Win + X and select "Terminal (Admin)" 64 | - Run the following command: 65 | ```powershell 66 | Stop-Process -Name explorer -Force; Start-Process explorer 67 | ``` 68 | 69 | This command will close and restart Windows Explorer, which should refresh your context menu without requiring a full system restart. 🔄🖱️ 70 | 71 | ## 🗑️ Uninstallation 72 | 73 | 1. Download the `uninstall-open-with-cursor.ps1` script from https://github.com/Puliczek/open-with-cursor-context-menu/raw/main/uninstall-open-with-cursor.ps1 74 | 2. Right-click on the downloaded script and select "Run with PowerShell". 75 | 3. If prompted, allow the script to run with administrator privileges. 76 | 77 | The script will remove all "Open with Cursor" entries from your context menus. ❌ 78 | 79 | ## 🛠️ How It Works 80 | 81 | ### Installation Script 📥 82 | 83 | The `install-open-with-cursor.ps1` script: 84 | 85 | 1. Checks for administrator privileges and re-launches with elevated rights if necessary. 86 | 2. Locates the Cursor executable in the default installation directory. 87 | 3. Adds registry entries for the context menu options. 88 | 89 | ### Uninstallation Script 🗑️ 90 | 91 | The `uninstall-open-with-cursor.ps1` script: 92 | 93 | 1. Checks for administrator privileges and re-launches with elevated rights if necessary. 94 | 2. Removes the registry entries added by the installation script. 95 | 96 | ## 📝 Notes 97 | 98 | - Both scripts require administrator privileges to modify the registry. 99 | - The installation script assumes Cursor is installed in its default location. If you've installed Cursor in a different location, you may need to modify the script. 100 | 101 | ## 🤝 Contributing 102 | 103 | Feel free to fork this project and submit pull requests for any improvements or bug fixes. 104 | 105 | ## 📄 License 106 | 107 | This project is open source and available under the [MIT License](LICENSE). 📜 108 | -------------------------------------------------------------------------------- /cursorOpenFolder.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal enabledelayedexpansion 3 | 4 | :: Find Cursor.exe path 5 | set "cursor_path=" 6 | for %%i in (Cursor.exe) do set "cursor_path=%%~$PATH:i" 7 | if not defined cursor_path ( 8 | set "cursor_path=%LOCALAPPDATA%\Programs\Cursor\Cursor.exe" 9 | ) 10 | 11 | if not exist "!cursor_path!" ( 12 | echo Cursor.exe not found. Please ensure it's installed and in the PATH. 13 | pause 14 | exit /b 1 15 | ) 16 | 17 | :: Escape backslashes in the path 18 | set "cursor_path_escaped=!cursor_path:\=\\!" 19 | 20 | :: Define registry operations 21 | ( 22 | echo Windows Registry Editor Version 5.00 23 | 24 | echo [HKEY_CLASSES_ROOT\*\shell\Open with Cursor] 25 | echo @="Edit with Cursor" 26 | echo "Icon"="!cursor_path_escaped!,0" 27 | echo "Position"="" 28 | 29 | echo [HKEY_CLASSES_ROOT\*\shell\Open with Cursor\command] 30 | echo @="\"!cursor_path_escaped!\" \"%%1\"" 31 | 32 | echo [HKEY_CLASSES_ROOT\Directory\shell\Cursor] 33 | echo @="Open Folder as Cursor Project" 34 | echo "Icon"="\"!cursor_path_escaped!\",0" 35 | echo "Position"="" 36 | 37 | echo [HKEY_CLASSES_ROOT\Directory\shell\Cursor\command] 38 | echo @="\"!cursor_path_escaped!\" \"%%1\"" 39 | 40 | echo [HKEY_CLASSES_ROOT\Directory\Background\shell\Cursor] 41 | echo @="Open Folder as Cursor Project" 42 | echo "Icon"="\"!cursor_path_escaped!\",0" 43 | echo "Position"="" 44 | 45 | echo [HKEY_CLASSES_ROOT\Directory\Background\shell\Cursor\command] 46 | echo @="\"!cursor_path_escaped!\" \"%%V\"" 47 | ) > temp.reg 48 | 49 | :: Import registry file 50 | reg import temp.reg 51 | if %errorlevel% neq 0 ( 52 | echo Failed to import registry entries. 53 | goto cleanup 54 | ) 55 | 56 | echo Registry entries added successfully. 57 | echo Cursor.exe path: !cursor_path! 58 | 59 | :cleanup 60 | :: Delete temporary file 61 | @REM del temp.reg 62 | del temp.reg 63 | 64 | pause 65 | -------------------------------------------------------------------------------- /image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Puliczek/open-with-cursor-context-menu/cb013a8f2bd44f3ce2da74c3defd34806c9e22a5/image.png -------------------------------------------------------------------------------- /install-open-with-cursor.ps1: -------------------------------------------------------------------------------- 1 | # Check if running with administrator privileges 2 | $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) 3 | 4 | if (-not $isAdmin) { 5 | # Relaunch the script with admin rights 6 | Start-Process powershell.exe -Verb RunAs -ArgumentList ("-File", $MyInvocation.MyCommand.Path) 7 | exit 8 | } 9 | 10 | # Define the Cursor executable path 11 | $cursorExePath = [System.IO.Path]::Combine($env:LOCALAPPDATA, "Programs", "cursor", "Cursor.exe") 12 | 13 | # Check if the Cursor executable exists 14 | if (Test-Path $cursorExePath) { 15 | 16 | function Run-RegCommand { 17 | param ( 18 | [string]$command 19 | ) 20 | $process = Start-Process -FilePath "reg.exe" -ArgumentList $command -NoNewWindow -Wait -PassThru 21 | if ($process.ExitCode -ne 0) { 22 | Write-Host "Failed to execute: reg.exe $command" 23 | exit 1 24 | } 25 | } 26 | 27 | # Install context menu for background 28 | $backgroundPath = "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Cursor" 29 | Run-RegCommand "ADD `"$backgroundPath`" /ve /d `"Open with Cursor`" /f" 30 | Run-RegCommand "ADD `"$backgroundPath`" /v Icon /d `"$cursorExePath`" /f" 31 | Run-RegCommand "ADD `"$backgroundPath\command`" /ve /d `"\`"$cursorExePath\`" \`"%V\`"`" /f" 32 | Write-Host "Context menu for background installed successfully." 33 | 34 | # # Install context menu for folders 35 | $folderPath = "HKEY_CLASSES_ROOT\Directory\shell\Open with Cursor" 36 | Run-RegCommand "ADD `"$folderPath`" /ve /d `"Open with Cursor`" /f" 37 | Run-RegCommand "ADD `"$folderPath`" /v Icon /d `"$cursorExePath`" /f" 38 | Run-RegCommand "ADD `"$folderPath\command`" /ve /d `"\`"$cursorExePath\`" \`"%1\`"`" /f" 39 | Write-Host "Context menu for folders installed successfully." 40 | 41 | # Install context menu for files 42 | $filePath = "HKEY_CLASSES_ROOT\*\shell\Open with Cursor" 43 | Run-RegCommand "ADD `"$filePath`" /ve /d `"Open with Cursor`" /f" 44 | Run-RegCommand "ADD `"$filePath`" /v Icon /d `"$cursorExePath`" /f" 45 | Run-RegCommand "ADD `"$filePath\command`" /ve /d `"\`"$cursorExePath\`" \`"%1\`"`" /f" 46 | Write-Host "Context menu for files installed successfully." 47 | 48 | } else { 49 | Write-Host "Error: Cursor executable not found at $cursorExePath" 50 | } 51 | 52 | Write-Host "Press any key to exit..." 53 | $null = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown") 54 | -------------------------------------------------------------------------------- /uninstall-open-with-cursor.ps1: -------------------------------------------------------------------------------- 1 | # Check if running with administrator privileges 2 | $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) 3 | 4 | if (-not $isAdmin) { 5 | # Relaunch the script with admin rights 6 | Start-Process powershell.exe -Verb RunAs -ArgumentList ("-File", $MyInvocation.MyCommand.Path) 7 | exit 8 | } 9 | 10 | function Run-RegCommand { 11 | param ( 12 | [string]$command 13 | ) 14 | $process = Start-Process -FilePath "reg.exe" -ArgumentList $command -NoNewWindow -Wait -PassThru 15 | if ($process.ExitCode -ne 0) { 16 | Write-Host "Failed to execute: reg.exe $command" 17 | exit 1 18 | } 19 | } 20 | 21 | # Remove context menu for background 22 | $backgroundPath = "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Cursor" 23 | Run-RegCommand "DELETE `"$backgroundPath`" /f" 24 | Write-Host "Context menu for background removed successfully." 25 | 26 | # Remove context menu for folders 27 | $folderPath = "HKEY_CLASSES_ROOT\Directory\shell\Open with Cursor" 28 | Run-RegCommand "DELETE `"$folderPath`" /f" 29 | Write-Host "Context menu for folders removed successfully." 30 | 31 | # Remove context menu for files 32 | $filePath = "HKEY_CLASSES_ROOT\*\shell\Open with Cursor" 33 | Run-RegCommand "DELETE `"$filePath`" /f" 34 | Write-Host "Context menu for files removed successfully." 35 | 36 | Write-Host "Cursor context menu entries have been removed." 37 | Write-Host "Press any key to exit..." 38 | $null = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown") 39 | --------------------------------------------------------------------------------