Repository navigation
Expand file tree
/
Copy pathRemoveFromContextMenu.ps1
More file actions
83 lines (74 loc) · 3.22 KB
/
Copy pathRemoveFromContextMenu.ps1
File metadata and controls
83 lines (74 loc) · 3.22 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Script to remove the FileMoveCopy tool from Windows Explorer context menu
# Function to remove context menu for files - Move
function Remove-FileMoveContextMenu {
$keyPath = 'Registry::HKEY_CLASSES_ROOT\*\shell\MoveFiles'
if (Test-Path -LiteralPath $keyPath) {
Remove-Item -LiteralPath $keyPath -Recurse -Force
Write-Host "Removed FileMove context menu for files."
} else {
Write-Host "FileMove context menu for files not found."
}
}
# Function to remove context menu for files - Copy
function Remove-FileCopyContextMenu {
$keyPath = 'Registry::HKEY_CLASSES_ROOT\*\shell\CopyFiles'
if (Test-Path -LiteralPath $keyPath) {
Remove-Item -LiteralPath $keyPath -Recurse -Force
Write-Host "Removed FileCopy context menu for files."
} else {
Write-Host "FileCopy context menu for files not found."
}
}
# Function to remove context menu for folders - Move
function Remove-FolderMoveContextMenu {
$keyPath = 'Registry::HKEY_CLASSES_ROOT\Folder\shell\FileMove'
if (Test-Path -LiteralPath $keyPath) {
Remove-Item -LiteralPath $keyPath -Recurse -Force
Write-Host "Removed FileMove context menu for folders."
} else {
Write-Host "FileMove context menu for folders not found."
}
}
# Function to remove context menu for folders - Copy
function Remove-FolderCopyContextMenu {
$keyPath = 'Registry::HKEY_CLASSES_ROOT\Folder\shell\FileCopy'
if (Test-Path -LiteralPath $keyPath) {
Remove-Item -LiteralPath $keyPath -Recurse -Force
Write-Host "Removed FileCopy context menu for folders."
} else {
Write-Host "FileCopy context menu for folders not found."
}
}
# Function to remove context menu for directory background - Move
function Remove-DirectoryBackgroundMoveContextMenu {
$keyPath = 'Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\FileMove'
if (Test-Path -LiteralPath $keyPath) {
Remove-Item -LiteralPath $keyPath -Recurse -Force
Write-Host "Removed FileMove context menu for directory background."
} else {
Write-Host "FileMove context menu for directory background not found."
}
}
# Function to remove context menu for directory background - Copy
function Remove-DirectoryBackgroundCopyContextMenu {
$keyPath = 'Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\FileCopy'
if (Test-Path -LiteralPath $keyPath) {
Remove-Item -LiteralPath $keyPath -Recurse -Force
Write-Host "Removed FileCopy context menu for directory background."
} else {
Write-Host "FileCopy context menu for directory background not found."
}
}
# Run as administrator check
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host "Please run this script as Administrator to modify the registry."
exit
}
# Remove the context menus
Remove-FileMoveContextMenu
Remove-FileCopyContextMenu
Remove-FolderMoveContextMenu
Remove-FolderCopyContextMenu
Remove-DirectoryBackgroundMoveContextMenu
Remove-DirectoryBackgroundCopyContextMenu
Write-Host "Context menu items removed. You may need to restart Explorer or log off/log on for changes to take effect."