Created
February 24, 2019 16:41
-
-
Save logchan/3f9762291c2c93193e0d94d2d5cbcae6 to your computer and use it in GitHub Desktop.
Remove the "Move to OneDrive" context menu item permanently by clearing the values of the registry keys and denying access.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -RunAsAdministrator | |
New-PSDrive -Name HKCR_RMTO -PSProvider Registry -Root 'HKEY_CLASSES_ROOT' | |
pushd HKCR_RMTO: | |
$keys = '*\shellex\ContextMenuHandlers\ FileSyncEx', 'Directory\Background\shellex\ContextMenuHandlers\ FileSyncEx', 'Directory\shellex\ContextMenuHandlers\ FileSyncEx', 'IE.AssocFile.URL\shellex\ContextMenuHandlers\ FileSyncEx', 'lnkfile\shellex\ContextMenuHandlers\ FileSyncEx' | |
$rights = 'ChangePermissions', 'CreateSubKey', 'Delete', 'FullControl', 'SetValue', 'TakeOwnership', 'WriteKey' | |
foreach ($key in $keys) { | |
REG DELETE "HKEY_CLASSES_ROOT\$key" /ve /f | |
$reg = "\$key" | |
$acl = Get-Acl -LiteralPath $reg | |
foreach ($right in $rights) { | |
$rule = New-Object System.Security.AccessControl.RegistryAccessRule("everyone",$right,"Deny") | |
$acl.AddAccessRule($rule) | |
} | |
$acl | Format-List | |
Set-Acl -LiteralPath $reg -AclObject $acl | |
} | |
popd | |
Remove-PSDrive -Name HKCR_RMTO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment