Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @(set ^ "0=%~f0" -des ') &set 1=%*& powershell -nop -c iex(out-string -i (gc -lit $env:0)) & exit /b ')
- # AveYo: place this nvidia_hdcp_toggle.bat in the CRU tool folder to take effect without restart
- $n0 = 'NVIDIA HDCP TOGGLE'
- $s0 = 'active'
- (gp "HKLM:\SYSTEM\CurrentControlSet\Control\Video\*\*") | where {$_.ProviderName -eq "NVIDIA"} | foreach {
- if (gp $_.PSPath RMHdcpKeyglobZero -ea 0) { $s0 = 'inactive' } }
- #:: Args / Dialog - to skip the prompt can use commandline parameters or rename script: nvidia_hdcp_enable.bat
- $do = ''; $cl = @{0 = 'enable'; 1 = 'disable'; 2 = 'cancel'} ; if (!$env:0) {$env:0 = "$pwd\.pasted"}
- foreach ($a in $cl.Values) {if ("$(split-path $env:0 -leaf) $env:1" -like "*$a*") {$do = $a} }
- if ($do -eq '') {
- $choice = (new-object -ComObject Wscript.Shell).Popup("state: $s0", 0, $n0, 0x1043)
- if ($choice -eq 2) {$do = $cl[2]} elseif ($choice -eq 7) {$do = $cl[1]} else {$do = $cl[0]} ; $env:1 = $do
- if ($do -eq 'cancel') {return}
- }
- $cc = {
- [Console]::Title = "$($args[2]) $($args[1])"
- $do = $args[1]; if ($args[0]) { pushd -lit $(split-path $args[0]) }
- (gp "HKLM:\SYSTEM\CurrentControlSet\Control\Video\*\*") | where {$_.ProviderName -eq "NVIDIA"} | foreach {
- if ($do -eq 'enable') { rp $_.PSPath RMHdcpKeyglobZero -force -ea 0; "AveYo: +HDCP" }
- elseif ($do -eq 'disable') { sp $_.PSPath RMHdcpKeyglobZero 1 -type dword -force -ea 0; "AveYo: -HDCP" }
- }
- if (test-path restart64.exe) { .\restart64.exe /q } # part of CRU tool
- }
- if ([Security.Principal.WindowsIdentity]::GetCurrent().Groups.Value -notcontains 'S-1-5-32-544') {
- write-host " Requesting ADMIN rights.. " -fore Black -back Yellow; sleep 2
- sp HKCU:\Volatile*\* $n0 ".{$cc} '$($env:0-replace"'","''")' '$($env:1-replace"'","''")' '$n0'" -force -ea 0
- start powershell -args " -nop -c iex(gp Registry::HKU\S-1-5-21*\Volatile*\* '$n0' -ea 0).'$n0'" -verb runas
- } else {. $cc "$env:0" "$env:1" "$n0" }
- $Press_Enter_if_pasted_in_powershell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement