Advertisement
aveyo

Hush_Windows

Jul 14th, 2018
2,489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 9.61 KB | None | 0 0
  1. @set @v=2018.07.17  /*& title Hush Windows
  2. @echo off &echo. &color 07 &if %1.==T. goto toggle
  3. :about
  4. echo      ---------------------------------------------------------------------
  5. echo     :  AveYo                 Hush Windows 1.6                v%@v:  /*=%  :
  6. echo     :---------------------------------------------------------------------:
  7. echo     :          Check hush options in the GUI menu about to show:          :
  8. echo     :   Block Update/Nagging/Telemetry/Diag/Bundle/Input/Cortana/UWPApps  :
  9. echo     :   Switch Defender Realtime+Behavior+IOAV          Restart Explorer  :
  10. echo     :                                                                     :
  11. echo     :     Toggle from the comfort of Desktop right-click context menu     :
  12. echo     :      Run script again to uninstall / reinstall with new choices     :
  13. echo     :                                                                     :
  14. echo     :      ClassicShell recommended if turning off Cortana or UWPApps     :
  15. echo     :  then CSM Settings-Backup-Load XML: https://pastebin.com/9atGBx6D   :
  16. echo      ---------------------------------------------------------------------
  17. :setup
  18. :: setup ifeo exe blocking gui dialog choices
  19. set Update=wuauclt sihclient usoclient WaaSMedic remsh SetupHost setupprep
  20. set Nagging=EOSNotify MusNotification MusNotifyIcon Windows10UpgraderApp Windows10Upgrade WindowsUpdateBox DFDWiz
  21. set Telemetry=CompatTelRunner wsqmcons dusmtask dmclient dstokenclean appidtel devicecensus DiskSnapshot SpeechRuntime
  22. set Diag=WerFault wermgr DiagTrackRunner DiagnosticsHub.StandardCollector.Service
  23. set Bundle_OneDrive=SpeechModelDownload HxOutlook HxTsr OneDrive OneDriveSetup OneDriveStandaloneUpdater FileCoAuth
  24. set BackgroundTask=backgroundTaskHost
  25. set Defender=MpCmdRunDummy
  26. set Cortana=SearchUI
  27. set InputApp=WindowsInternal.ComposableShell.Experiences.TextInput.InputApp TabTip
  28. set Indexer=SearchIndexer SearchFilterHost SearchProtocolHost
  29. set wuauserv=wuauserv
  30. set UWPApps=RuntimeBroker &rem ApplicationFrameHost
  31. :: setup gui dialog choices
  32. set all_choices=Update,Nagging,Telemetry,Diag,Bundle_OneDrive,BackgroundTask,Defender,Cortana,InputApp,Indexer,wuauserv,UWPApps
  33. set def_choices=Update,Nagging,Telemetry,Diag,Bundle_OneDrive,BackgroundTask,Defender
  34. :: check admin rights
  35. reg query "HKEY_USERS\S-1-5-20\Environment" /v TEMP >nul 2>nul || goto needs_admin_rights
  36. echo.
  37. :: Uninstall if present
  38. call :reg_query "HKLM\SOFTWARE\AveYo" "Hush exe" uninstall_if_present
  39. if defined uninstall_if_present (
  40.  reg add HKCR\DesktopBackground\shell\HushWindows /v Icon /d "ieframe.dll,38" /f
  41.  call :toggle
  42.  del /f /q %Windir%\HushWindows.bat >nul
  43.  schtasks /Delete /TN HushWindows /f >nul
  44.  reg delete HKCR\DesktopBackground\shell\HushWindows /f >nul
  45.  reg delete HKLM\SOFTWARE\AveYo /v "Hush exe" /f >nul
  46.  echo. &echo  UNINSTALLED! Run script again to reinstall with new choices..
  47.  timeout /t -1
  48.  exit
  49. ) 2>nul
  50. :: Show gui dialog choices arguments: title all_choices def_choices outputvar
  51. call :choices "Hush choices" "%all_choices%" "%def_choices%" CHOICES
  52. if not defined CHOICES color 0c &echo  ERROR! No choice selected.. &timeout /t 20 &color 07 &exit/b
  53. echo Choices: %CHOICES% & echo.
  54. call :reg_query "HKCU\Environment" "Hush choices" CHOICES
  55. if not defined CHOICES set CHOICES=Telemetry,Report,Nagging,Update,Search,Input,Live
  56. set "exe=" &for %%# in (%CHOICES%) do call set "exe=%%exe%%%%%%#%% "
  57. reg add "HKLM\SOFTWARE\AveYo" /v "Hush exe" /t REG_SZ /d "%exe%" /f >nul 2>nul
  58. call :reg_query "HKLM\SOFTWARE\AveYo" "Hush exe" exe
  59. echo Blocked: %exe% & echo.
  60. :: setup task
  61. set "f0=%Windir%\HushWindows.bat"
  62. if /i "%~f0"=="%f0%" (set "COPY2WINDIR=") else echo|set/p=%f0% &copy /y "%~f0" "%f0%" &set "COPY2WINDIR=yes"
  63. set "TASK_RUN_ADMIN=wscript.exe /e:JScript \"%f0%\" T"
  64. schtasks /create /ru "%username%" /sc once /tn HushWindows /tr "%TASK_RUN_ADMIN%" /sd "01/01/2030" /st "00:00:00" /it /rl highest /f
  65. :: setup desktop context-menu
  66. set "menu=HKCR\DesktopBackground\shell\HushWindows"
  67. (
  68. reg add %menu% /ve /d "Hush Windows" /f
  69. reg add %menu% /v MUIVerb /d "Hush Windows" /f
  70. reg add %menu% /v Position /d "middle" /f
  71. reg add %menu% /v Icon /d "ieframe.dll,39" /f
  72. reg add %menu%\command /ve /d "wscript.exe /e:JScript \"%f0%\" M" /f
  73. ) >nul
  74. :: trigger initial state = blocked
  75. call :toggle
  76. :: all done!
  77. echo Now toggle blocking on/off via [ Hush Windows ] Desktop context-menu entry..
  78. timeout /t -1
  79. exit
  80.  
  81. :toggle
  82. call :reg_query "HKLM\SOFTWARE\AveYo" "Hush exe" exe
  83. for /f "tokens=2 delims=," %%# in ('reg query HKCR\DesktopBackground\shell\HushWindows /v Icon') do set/a "icon=%%#"
  84. if %icon% gtr 38 (set "icon=38" &set "OP=add" &set "NOOP=") else set "icon=39" &set "OP=delete" &set "NOOP=/f >nul 2>nul &rem"
  85. :: add temporary context-menu icon
  86. reg add HKCR\DesktopBackground\shell\HushWindows /v Icon /d "ieframe.dll,11" /f >nul 2>nul
  87. :: toggle ifeo executables blocking and taskkill
  88. set "ifeo=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
  89. for %%# in (%exe%) do reg %OP% "%ifeo%\%%#.exe" %NOOP% /v Debugger /d NUL /f >nul 2>nul &call set "killer=/im %%#.exe %%killer%%"
  90. taskkill %killer% /im TiWorker.exe /t /f >nul 2>nul
  91. :: restart explorer
  92. if defined NOOP (taskkill /im explorer.exe /f & taskkill /im sihost.exe /f)
  93. :: toggle windows update service
  94. if defined NOOP (set "blocked=rpcss") else set "blocked=rpcss[HushWindows]"
  95. set "WUS=%exe:wuauserv=%"
  96. if "%WUS%"=="%exe%" set "WUS="
  97. if defined WUS net stop wuauserv /y >nul 2>nul
  98. if defined WUS for /f "tokens=3" %%# in ('sc queryex wuauserv ^| find /i "PID"') do set "pid=%#"
  99. if defined WUS if not "%pid%"=="0" taskkill /pid %pid% /f >nul 2>nul
  100. if defined WUS sc config wuauserv type= share depend= %blocked% >nul 2>nul
  101. :: toggle defender and set sig update priority if WU is disabled
  102. if defined NOOP (set "toggle=0") else set "toggle=1"
  103. set "DEF=%exe:MpCmdRunDummy=%"
  104. if "%DEF%"=="%exe%" set "DEF="
  105. set "DefSig={MicrosoftUpdateServer|MMPC|InternalDefinitionUpdateServer}"
  106. set "DefMMPC={MMPC|MicrosoftUpdateServer|InternalDefinitionUpdateServer}"
  107. set "WUA=%exe:wuauclt=%"
  108. if "%WUA%"=="%exe%" set "WUA="
  109. if defined WUA set "DefSig=%DefMMPC%"
  110. if defined WUS set "DefSig=%DefMMPC%"
  111. set "DefPS1=Set-MpPreference -SignatureFallbackOrder %DefSig%; Set-MpPreference -DisableBehaviorMonitoring $t;"
  112. set "DefPS2=Set-MpPreference -DisableIOAVProtection $t; Set-MpPreference -DisableRealtimeMonitoring $t;"
  113. if defined DEF powershell -c "$t=%toggle%; %DefPS1%; %DefPS2%;"
  114. :: done, update context-menu icon
  115. reg add HKCR\DesktopBackground\shell\HushWindows /v Icon /d "ieframe.dll,%icon%" /f >nul 2>nul
  116. exit/b
  117.  
  118. :choices %1:title %2:all_choices %3:def_choices %4:output_variable          GUI dialog with autosize checkboxes - outputs %CHOICES%
  119. setlocal &set "parameters=$n='%~1'; $all='%~2'; $def='%~3'; $p='HKCU:\Environment'; $pad=32;"
  120. set "s1=[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); $f=New-Object System.Windows.Forms.Form;"
  121. set "s2=[void][System.Reflection.Assembly]::LoadWithPartialName('System.Drawing'); $f.Forecolor='Black';$f.BackColor='WhiteSmoke';"
  122. set "s3=$r=(Get-ItemProperty $p).$n; if($r -ne $null){$opt=$r.split(',')}else{$opt=$def.split(',')}; function CLK(){ $v=@();"
  123. set "s4=foreach($x in $cb){if($x.Checked){$v+=$x.Text}}; New-ItemProperty -Path $p -Name $n -Value $($v -join ',') -Force };"
  124. set "s5=$BCLK=@(0, {CLK}, {foreach($z in $cb){$z.Checked=$false;if($def.split(',') -contains $z.Text){$z.Checked=$true}};CLK});"
  125. set "s6=$i=1; $cb=foreach($l in $all.split(',')){$c=New-Object System.Windows.Forms.CheckBox; $c.Name='c$i'; $c.AutoSize=$true;"
  126. set "s7=$c.Text=$l; $c.Location=New-Object System.Drawing.Point(($pad*2.5),(16+(($i-1)*24))); $c.BackColor='Transparent';"
  127. set "s8=$c.add_Click({CLK}); $f.Controls.Add($c); $c; $i++; }; foreach($s in $cb){if($opt -contains $s.Text){$s.Checked=$true}};"
  128. set "s9=$j=1; $bn=@('OK','Reset');foreach($t in $bn){ $b=New-Object System.Windows.Forms.Button; $b.BackColor='Transparent';"
  129. set "s10=$b.Location=New-Object System.Drawing.Point(($pad*2+($j-1)*$pad*3),(32+(($i-1)*24))); $b.Margin='0,0,72,20';"
  130. set "s11=$b.add_Click($BCLK[$j]); if ($t -eq 'OK'){$b.DialogResult=1;$f.AcceptButton=$b}; $b.Name='b$j'; $b.Text=$t;"
  131. set "s12=$f.Controls.Add($b);$j++;}; $f.Text=$n; $f.FormBorderStyle='Fixed3D'; $f.AutoSize=$true; $f.AutoSizeMode='GrowAndShrink';"
  132. set "s13=$f.MaximizeBox=$false; $f.StartPosition='CenterScreen'; $f.Add_Shown({$f.Activate()}); $ret=$f.ShowDialog();"
  133. set "s14=if ($ret -ne 1) {Remove-ItemProperty -Path $p -Name $n -Force  -erroraction 'silentlycontinue' | out-null}"
  134. set "s15=else {write-host (Get-ItemProperty -Path $p -Name $n).$n;}"
  135. for /l %%# in (1,1,15) do call set "ps_Choices=%%ps_Choices%%%%s%%#:"=\"%%"
  136. for /f "usebackq tokens=* delims=" %%# in (`powershell -c "%parameters% %ps_Choices%"`) do set "choices_var=%%#"
  137. endlocal & set "%~4=%choices_var%" & exit/b &rem snippet by AveYo released under MIT License
  138.  
  139. :reg_query %1:KeyName %2:ValueName %3:OutputVariable %4:other_options[example: /t REG_DWORD]
  140. setlocal & for /f "skip=2 delims=" %%s in ('reg query "%~1" /v "%~2" %4 /z 2^>nul') do set "rq=%%s" & call set "rv=%%rq:*)    =%%"
  141. endlocal & set "%~3=%rv%" & exit/b                                              AveYo: call :reg_query "HKCU\MyKey" "MyValue" MyVar
  142.  
  143. :needs_admin_rights
  144. color 0c&echo. &echo  PERMISSION DENIED! Right-click %~nx0 ^& Run as administrator &timeout /t 60 &color 0f&title %COMSPEC% &exit/b
  145.  
  146. :context_menu_windowless_toggle */
  147. if (WSH.Arguments(0)=='M') WSH.CreateObject('Shell.Application').ShellExecute('schtasks.exe','/Run /TN HushWindows','','',0);
  148. else WSH.CreateObject('Shell.Application').ShellExecute('cmd.exe','/c call "'+WSH.ScriptFullName+'" T','','',0);
  149. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement