Skip to content

Commit

Permalink
v3.7.5
Browse files Browse the repository at this point in the history
- right click menu function relocated under programs
- delete git, treesize and vscode from right click menu
  • Loading branch information
caglaryalcin committed Mar 13, 2024
1 parent b301ad7 commit fcd0de1
Showing 1 changed file with 89 additions and 80 deletions.
169 changes: 89 additions & 80 deletions w11.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -383,86 +383,6 @@ Function SystemSettings {

DisableSnap

Function RightClickMenu {
Write-Host `n"Editing the right click menu for Windows 11..." -NoNewline
try {
# New PS Drives
New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null

# Old right click menu
$regPath = "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"
reg.exe add $regPath /f /ve *>$null

$contextMenuPaths = @(
"HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\SendTo", #remove send to
"HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\SendTo", #remove send to
"HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing", #remove share
"HKEY_CLASSES_ROOT\*\shell\pintohomefile", #remove favorites
#remove give access
"HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\LibraryFolder\background\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\Sharing",
#remove previous
"HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}",
"HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}",
"HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}",
"HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}"
)

foreach ($path in $contextMenuPaths) {
$regPath = $path -replace 'HKCR:\\', 'HKEY_CLASSES_ROOT\'
$cmd = "reg delete `"$regPath`" /f"

Invoke-Expression $cmd *>$null
}

# New hash menu for right click
$regpath = "HKEY_CLASSES_ROOT\*\shell\hash"
$sha256menu = "HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu"
$md5menu = "HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu"

reg add $regpath /f *>$null
reg add $regpath /v "MUIVerb" /t REG_SZ /d HASH /f *>$null
reg add $regpath /v "SubCommands" /t REG_SZ /d """" /f *>$null
reg add "$regpath\shell" /f *>$null

reg add "$sha256menu" /f *>$null
reg add "$sha256menu\command" /f *>$null
reg add "$sha256menu" /v "MUIVerb" /t REG_SZ /d SHA256 /f *>$null

$tempOut = [System.IO.Path]::GetTempFileName()
$tempErr = [System.IO.Path]::GetTempFileName()
Start-Process cmd.exe -ArgumentList '/c', 'reg add "HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu\command" /ve /d "powershell -noexit get-filehash -literalpath \"%1\" -algorithm SHA256 | format-list" /f' -NoNewWindow -RedirectStandardOutput $tempOut -RedirectStandardError $tempErr
Remove-Item $tempOut -ErrorAction Ignore
Remove-Item $tempErr -ErrorAction Ignore

reg add "$md5menu" /f *>$null
reg add "$md5menu\command" /f *>$null
reg add "$md5menu" /v "MUIVerb" /t REG_SZ /d MD5 /f *>$null

$tempOut = [System.IO.Path]::GetTempFileName()
$tempErr = [System.IO.Path]::GetTempFileName()
Start-Process cmd.exe -ArgumentList '/c', 'reg add "HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu\command" /ve /d "powershell -noexit get-filehash -literalpath \"%1\" -algorithm MD5 | format-list" /f' -NoNewWindow -RedirectStandardOutput $tempOut -RedirectStandardError $tempErr
Remove-Item $tempOut -ErrorAction Ignore
Remove-Item $tempErr -ErrorAction Ignore

# Restart Windows Explorer
taskkill /f /im explorer.exe *>$null
Start-Sleep 1
Start-Process "explorer.exe" -ErrorAction Stop

Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}

RightClickMenu

# Disable Gallery for Windows 11
Function DisableGallery {
Write-Host "Disabling gallery folder..." -NoNewline
Expand Down Expand Up @@ -3589,6 +3509,95 @@ Function UnusedApps {
}

UninstallEdge

# The function is here because programs add themselves to the right click menu after loading
Function RightClickMenu {
Write-Host `n"Editing the right click menu for Windows 11..." -NoNewline
try {
# New PS Drives
New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null

# Old right click menu
$regPath = "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"
reg.exe add $regPath /f /ve *>$null

$contextMenuPaths = @(
"HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\SendTo", #remove send to
"HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\SendTo", #remove send to
"HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing", #remove share
"HKEY_CLASSES_ROOT\*\shell\pintohomefile", #remove favorites
#remove give access
"HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\LibraryFolder\background\shellex\ContextMenuHandlers\Sharing",
"HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\Sharing",
#remove previous
"HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}",
"HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}",
"HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}",
"HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}",
#remove git
"HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui",
"HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell",
#remove treesize
"HKEY_CLASSES_ROOT\Directory\Background\shell\TreeSize Free",
"HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode"

#
)

foreach ($path in $contextMenuPaths) {
$regPath = $path -replace 'HKCR:\\', 'HKEY_CLASSES_ROOT\'
$cmd = "reg delete `"$regPath`" /f"

Invoke-Expression $cmd *>$null
}

# New hash menu for right click
$regpath = "HKEY_CLASSES_ROOT\*\shell\hash"
$sha256menu = "HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu"
$md5menu = "HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu"

reg add $regpath /f *>$null
reg add $regpath /v "MUIVerb" /t REG_SZ /d HASH /f *>$null
reg add $regpath /v "SubCommands" /t REG_SZ /d """" /f *>$null
reg add "$regpath\shell" /f *>$null

reg add "$sha256menu" /f *>$null
reg add "$sha256menu\command" /f *>$null
reg add "$sha256menu" /v "MUIVerb" /t REG_SZ /d SHA256 /f *>$null

$tempOut = [System.IO.Path]::GetTempFileName()
$tempErr = [System.IO.Path]::GetTempFileName()
Start-Process cmd.exe -ArgumentList '/c', 'reg add "HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu\command" /ve /d "powershell -noexit get-filehash -literalpath \"%1\" -algorithm SHA256 | format-list" /f' -NoNewWindow -RedirectStandardOutput $tempOut -RedirectStandardError $tempErr
Remove-Item $tempOut -ErrorAction Ignore
Remove-Item $tempErr -ErrorAction Ignore

reg add "$md5menu" /f *>$null
reg add "$md5menu\command" /f *>$null
reg add "$md5menu" /v "MUIVerb" /t REG_SZ /d MD5 /f *>$null

$tempOut = [System.IO.Path]::GetTempFileName()
$tempErr = [System.IO.Path]::GetTempFileName()
Start-Process cmd.exe -ArgumentList '/c', 'reg add "HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu\command" /ve /d "powershell -noexit get-filehash -literalpath \"%1\" -algorithm MD5 | format-list" /f' -NoNewWindow -RedirectStandardOutput $tempOut -RedirectStandardError $tempErr
Remove-Item $tempOut -ErrorAction Ignore
Remove-Item $tempErr -ErrorAction Ignore

# Restart Windows Explorer
taskkill /f /im explorer.exe *>$null
Start-Sleep 1
Start-Process "explorer.exe" -ErrorAction Stop

Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black
}
catch {
Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black
}
}

RightClickMenu

}
elseif ($response -eq 'n' -or $response -eq 'N') {
Expand Down

0 comments on commit fcd0de1

Please sign in to comment.