-
Notifications
You must be signed in to change notification settings - Fork 4
/
uninstall-open-with-cursor.ps1
38 lines (32 loc) · 1.42 KB
/
uninstall-open-with-cursor.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Check if running with administrator privileges
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
# Relaunch the script with admin rights
Start-Process powershell.exe -Verb RunAs -ArgumentList ("-File", $MyInvocation.MyCommand.Path)
exit
}
function Run-RegCommand {
param (
[string]$command
)
$process = Start-Process -FilePath "reg.exe" -ArgumentList $command -NoNewWindow -Wait -PassThru
if ($process.ExitCode -ne 0) {
Write-Host "Failed to execute: reg.exe $command"
exit 1
}
}
# Remove context menu for background
$backgroundPath = "HKEY_CLASSES_ROOT\Directory\Background\shell\Open with Cursor"
Run-RegCommand "DELETE `"$backgroundPath`" /f"
Write-Host "Context menu for background removed successfully."
# Remove context menu for folders
$folderPath = "HKEY_CLASSES_ROOT\Directory\shell\Open with Cursor"
Run-RegCommand "DELETE `"$folderPath`" /f"
Write-Host "Context menu for folders removed successfully."
# Remove context menu for files
$filePath = "HKEY_CLASSES_ROOT\*\shell\Open with Cursor"
Run-RegCommand "DELETE `"$filePath`" /f"
Write-Host "Context menu for files removed successfully."
Write-Host "Cursor context menu entries have been removed."
Write-Host "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")