Advertisement
aveyo

nvidia_hdcp_toggle

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