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