Skip to content

Instantly share code, notes, and snippets.

@AveYo
AveYo / .Close_Handles_ContextMenu.bat
Last active December 29, 2023 17:45
'Close Handles' context menu to unlock files or folders - https://www.youtube.com/watch?v=BEcDwKTyAYY
@echo off &Title 'Close Handles' context menu to unlock files or folders by AveYo v2019.09.27
:: changelog: fix dl; add /accepteula; check S-1-5-19 for admin; ask for admin rights to catch system handles; auto-hide window
:: add_remove whenever script is run again
reg query "HKCU\Software\Classes\Directory\shell\CloseHandles" /v MuiVerb >nul 2>nul && (
reg delete HKCU\Software\Classes\Directory\shell\CloseHandles /f >nul 2>nul
reg delete HKCU\Software\Classes\Drive\shell\CloseHandles /f >nul 2>nul
reg delete HKCU\Software\Classes\*\shell\CloseHandles /f >nul 2>nul
color 0c &echo. &echo REMOVED! Run script again to add 'Close Handles' context menu
timeout /t -1 &color 0f &title %COMSPEC% &exit/b
@pldmgg
pldmgg / Sanitized-UpdatePackageManagement.ps1
Last active January 24, 2019 02:30
Update-PackageManagement_PowerShellCore_Errors
function Check-Elevation {
if ($PSVersionTable.PSEdition -eq "Desktop" -or $PSVersionTable.Platform -eq "Win32NT") {
[System.Security.Principal.WindowsPrincipal]$currentPrincipal = New-Object System.Security.Principal.WindowsPrincipal(
[System.Security.Principal.WindowsIdentity]::GetCurrent()
)
[System.Security.Principal.WindowsBuiltInRole]$administratorsRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator
if($currentPrincipal.IsInRole($administratorsRole)) {
return $true