Advertisement
Guest User

Untitled

a guest
Nov 28th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using namespace System.Security.AccessControl;
  2. using namespace System.Security.Principal;
  3. using namespace Microsoft.Win32;
  4.  
  5. if([WindowsIdentity]::GetCurrent().Groups -notcontains 'S-1-5-32-544') { Start-Process -FilePath "$($MyInvocation.MyCommand.Path)" -Verb RunAs; exit }
  6.  
  7. $cdKey = '1234-5678-9abc-dddf' + (-join ((97..122) | Get-Random -Count 5 | % {[char]$_}))
  8. Write-Host "Generated CD-Key: " -NoNewline
  9. Write-Host $cdKey -ForegroundColor ([ConsoleColor]::Red)
  10. $regPath = 'SOFTWARE\WOW6432Node\Illusion Softworks\Hidden & Dangerous 2'
  11. $regKey = [Registry]::LocalMachine.OpenSubKey($regPath, [RegistryKeyPermissionCheck]::ReadWriteSubTree, [RegistryRights]::ChangePermissions)
  12. $acl = $regKey.GetAccessControl()
  13. $acr = New-Object System.Security.AccessControl.RegistryAccessRule([NTAccount]'BUILTIN\Administrators', [RegistryRights]'SetValue, Delete', [InheritanceFlags]::ContainerInherit, [PropagationFlags]::None, [AccessControlType]::Deny)
  14. $acl.RemoveAccessRule($acr) | Out-Null
  15. $regKey.SetAccessControl($acl)
  16. Set-ItemProperty -Path ('HKLM:\\' + $regPath) -Name 'key' -Value $cdKey -Force
  17. $acl.SetAccessRule($acr)
  18. $regKey.SetAccessControl($acl)
  19. pause
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement