Advertisement
aveyo

windows_update_notifications_toggle

Mar 4th, 2018 (edited)
8,701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.30 KB | None | 0 0
  1. <# :: Windows Update Notifications-only Toggle, AveYo 2018-2022
  2. @set "0=%~f0" &set 1=%*& powershell -nop -c iex ([io.file]::ReadAllText($env:0)) & exit /b
  3. #>
  4.  
  5. $PS = {
  6.  $notify=@()
  7.  $notify += 'MusNotification','MusNotifyIcon','MoNotificationUx'          # UpdateOrchestrator
  8.  $notify += 'EOSNotify','GWX'                                             # End Of Support
  9.  $notify += 'UpdateNotificationMgr','UNPUXLauncher','UNPUXHost'           # Universal Notification Platform
  10. ## OPTIONAL:                                                              # OPTIONAL:
  11. #$notify += 'wermgr','WerFault','WerFaultSecure','DWWIN'                  # Windows Error Reporting
  12. #$notify += 'compattelrunner'                                             # Application Experience
  13. #$notify += 'dstokenclean','appidtel'                                     # ApplicationData
  14. #$notify += 'wsqmcons'                                                    # Customer Experience Improvement Prg
  15. #$notify += 'dusmtask'                                                    # DUSM
  16. #$notify += 'dmclient'                                                    # Feedback\Siuf
  17. #$notify += 'DataUsageLiveTileTask'                                       # {SID}\DataSenseLiveTileTask
  18. #$notify += 'DiagnosticsHub.StandardCollector.Service'                    # System32\DiagSvcs
  19. #$notify += 'HxTsr'                                                       # microsoft.windowscommunicationsapps
  20. #$notify += 'PilotshubApp'                                                # Microsoft.WindowsFeedbackHub_
  21. #$notify += 'SpeechModelDownload','SpeechRuntime'                         # Speech
  22. #$notify += 'LocationNotificationWindows','WindowsActionDialog'           # Location
  23.  
  24.  $ifeo='HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
  25.  if (gp "$ifeo\GWX.exe" Debugger -ea 0) {$TOGGLE=7;$KEEP=6;$A='Restore';$S='OFF'}else{$TOGGLE=6;$KEEP=7;$A='Disable';$S='ON'}
  26.  $dummy="$env:SystemRoot\System32\systray.exe"      
  27.  
  28. ## Comment to hide dialog prompt with Yes, No, Cancel (6,7,2)
  29.  if ($env:1 -ne 6 -and $env:1 -ne 7) {
  30.    $choice=(new-object -ComObject Wscript.Shell).Popup("$A Windows Update Notifications?", 0, "WU Notifications: $S", 0x1033)
  31.    if ($choice -eq 2) {return} elseif ($choice -eq 6) {$env:1=$TOGGLE; $1=$env:1} else {$env:1=$KEEP; $1=$env:1}
  32.  }
  33.  
  34. ## Without the dialog prompt above will toggle automatically
  35.  if ($env:1 -ne 6 -and $env:1 -ne 7) { $env:1=$TOGGLE }
  36.  
  37. ## Elevate passing $choice as $env:1
  38.  $admin = fltmc; if ($LASTEXITCODE) {
  39.    $i="`r (\   /)`r( * . * )   UAC is useless below Always-Notify`r    ```r"
  40.    start -verb runas -win 1 powershell -args "-nop -c & {`$i='$i'; `$env:1=$1; `$PS={$($PS -replace'"','\"')}; & `$PS}"; return
  41.  }
  42.  
  43. ## Undo upgrade entries in previous script versions since that goes above just notifications *facepalm*
  44.  'Windows10UpgraderApp','Windows10Upgrade','WindowsUpdateBox' |% {
  45.    if (gp "$ifeo\$_.exe" Debugger -ea 0) {ri "$ifeo\$_.exe" -Force -ea 0}
  46.  }
  47.  
  48. ## Toggle
  49.  if ($env:1 -eq 6) {
  50.    $notify |% {
  51.     kill -name $_ -force -ea 0
  52.     ni "$ifeo\$_.exe" -Force -ea 0|out-null
  53.     sp "$ifeo\$_.exe" Debugger $dummy -Force -ea 0
  54.    }
  55.  } else {
  56.    $notify |% {ri "$ifeo\$_.exe" -Force -ea 0}
  57.  }
  58.  
  59. #timeout -1
  60.  return
  61. }
  62.  
  63. & $PS
  64. #-_-# hybrid script, can be pasted directly into powershell console
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement