Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @set @v=2018.07.17 /*& title Hush Windows
- @echo off &echo. &color 07 &if %1.==T. goto toggle
- :about
- echo ---------------------------------------------------------------------
- echo : AveYo Hush Windows 1.6 v%@v: /*=% :
- echo :---------------------------------------------------------------------:
- echo : Check hush options in the GUI menu about to show: :
- echo : Block Update/Nagging/Telemetry/Diag/Bundle/Input/Cortana/UWPApps :
- echo : Switch Defender Realtime+Behavior+IOAV Restart Explorer :
- echo : :
- echo : Toggle from the comfort of Desktop right-click context menu :
- echo : Run script again to uninstall / reinstall with new choices :
- echo : :
- echo : ClassicShell recommended if turning off Cortana or UWPApps :
- echo : then CSM Settings-Backup-Load XML: https://pastebin.com/9atGBx6D :
- echo ---------------------------------------------------------------------
- :setup
- :: setup ifeo exe blocking gui dialog choices
- set Update=wuauclt sihclient usoclient WaaSMedic remsh SetupHost setupprep
- set Nagging=EOSNotify MusNotification MusNotifyIcon Windows10UpgraderApp Windows10Upgrade WindowsUpdateBox DFDWiz
- set Telemetry=CompatTelRunner wsqmcons dusmtask dmclient dstokenclean appidtel devicecensus DiskSnapshot SpeechRuntime
- set Diag=WerFault wermgr DiagTrackRunner DiagnosticsHub.StandardCollector.Service
- set Bundle_OneDrive=SpeechModelDownload HxOutlook HxTsr OneDrive OneDriveSetup OneDriveStandaloneUpdater FileCoAuth
- set BackgroundTask=backgroundTaskHost
- set Defender=MpCmdRunDummy
- set Cortana=SearchUI
- set InputApp=WindowsInternal.ComposableShell.Experiences.TextInput.InputApp TabTip
- set Indexer=SearchIndexer SearchFilterHost SearchProtocolHost
- set wuauserv=wuauserv
- set UWPApps=RuntimeBroker &rem ApplicationFrameHost
- :: setup gui dialog choices
- set all_choices=Update,Nagging,Telemetry,Diag,Bundle_OneDrive,BackgroundTask,Defender,Cortana,InputApp,Indexer,wuauserv,UWPApps
- set def_choices=Update,Nagging,Telemetry,Diag,Bundle_OneDrive,BackgroundTask,Defender
- :: check admin rights
- reg query "HKEY_USERS\S-1-5-20\Environment" /v TEMP >nul 2>nul || goto needs_admin_rights
- echo.
- :: Uninstall if present
- call :reg_query "HKLM\SOFTWARE\AveYo" "Hush exe" uninstall_if_present
- if defined uninstall_if_present (
- reg add HKCR\DesktopBackground\shell\HushWindows /v Icon /d "ieframe.dll,38" /f
- call :toggle
- del /f /q %Windir%\HushWindows.bat >nul
- schtasks /Delete /TN HushWindows /f >nul
- reg delete HKCR\DesktopBackground\shell\HushWindows /f >nul
- reg delete HKLM\SOFTWARE\AveYo /v "Hush exe" /f >nul
- echo. &echo UNINSTALLED! Run script again to reinstall with new choices..
- timeout /t -1
- exit
- ) 2>nul
- :: Show gui dialog choices arguments: title all_choices def_choices outputvar
- call :choices "Hush choices" "%all_choices%" "%def_choices%" CHOICES
- if not defined CHOICES color 0c &echo ERROR! No choice selected.. &timeout /t 20 &color 07 &exit/b
- echo Choices: %CHOICES% & echo.
- call :reg_query "HKCU\Environment" "Hush choices" CHOICES
- if not defined CHOICES set CHOICES=Telemetry,Report,Nagging,Update,Search,Input,Live
- set "exe=" &for %%# in (%CHOICES%) do call set "exe=%%exe%%%%%%#%% "
- reg add "HKLM\SOFTWARE\AveYo" /v "Hush exe" /t REG_SZ /d "%exe%" /f >nul 2>nul
- call :reg_query "HKLM\SOFTWARE\AveYo" "Hush exe" exe
- echo Blocked: %exe% & echo.
- :: setup task
- set "f0=%Windir%\HushWindows.bat"
- if /i "%~f0"=="%f0%" (set "COPY2WINDIR=") else echo|set/p=%f0% © /y "%~f0" "%f0%" &set "COPY2WINDIR=yes"
- set "TASK_RUN_ADMIN=wscript.exe /e:JScript \"%f0%\" T"
- schtasks /create /ru "%username%" /sc once /tn HushWindows /tr "%TASK_RUN_ADMIN%" /sd "01/01/2030" /st "00:00:00" /it /rl highest /f
- :: setup desktop context-menu
- set "menu=HKCR\DesktopBackground\shell\HushWindows"
- (
- reg add %menu% /ve /d "Hush Windows" /f
- reg add %menu% /v MUIVerb /d "Hush Windows" /f
- reg add %menu% /v Position /d "middle" /f
- reg add %menu% /v Icon /d "ieframe.dll,39" /f
- reg add %menu%\command /ve /d "wscript.exe /e:JScript \"%f0%\" M" /f
- ) >nul
- :: trigger initial state = blocked
- call :toggle
- :: all done!
- echo Now toggle blocking on/off via [ Hush Windows ] Desktop context-menu entry..
- timeout /t -1
- exit
- :toggle
- call :reg_query "HKLM\SOFTWARE\AveYo" "Hush exe" exe
- for /f "tokens=2 delims=," %%# in ('reg query HKCR\DesktopBackground\shell\HushWindows /v Icon') do set/a "icon=%%#"
- 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"
- :: add temporary context-menu icon
- reg add HKCR\DesktopBackground\shell\HushWindows /v Icon /d "ieframe.dll,11" /f >nul 2>nul
- :: toggle ifeo executables blocking and taskkill
- set "ifeo=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"
- for %%# in (%exe%) do reg %OP% "%ifeo%\%%#.exe" %NOOP% /v Debugger /d NUL /f >nul 2>nul &call set "killer=/im %%#.exe %%killer%%"
- taskkill %killer% /im TiWorker.exe /t /f >nul 2>nul
- :: restart explorer
- if defined NOOP (taskkill /im explorer.exe /f & taskkill /im sihost.exe /f)
- :: toggle windows update service
- if defined NOOP (set "blocked=rpcss") else set "blocked=rpcss[HushWindows]"
- set "WUS=%exe:wuauserv=%"
- if "%WUS%"=="%exe%" set "WUS="
- if defined WUS net stop wuauserv /y >nul 2>nul
- if defined WUS for /f "tokens=3" %%# in ('sc queryex wuauserv ^| find /i "PID"') do set "pid=%#"
- if defined WUS if not "%pid%"=="0" taskkill /pid %pid% /f >nul 2>nul
- if defined WUS sc config wuauserv type= share depend= %blocked% >nul 2>nul
- :: toggle defender and set sig update priority if WU is disabled
- if defined NOOP (set "toggle=0") else set "toggle=1"
- set "DEF=%exe:MpCmdRunDummy=%"
- if "%DEF%"=="%exe%" set "DEF="
- set "DefSig={MicrosoftUpdateServer|MMPC|InternalDefinitionUpdateServer}"
- set "DefMMPC={MMPC|MicrosoftUpdateServer|InternalDefinitionUpdateServer}"
- set "WUA=%exe:wuauclt=%"
- if "%WUA%"=="%exe%" set "WUA="
- if defined WUA set "DefSig=%DefMMPC%"
- if defined WUS set "DefSig=%DefMMPC%"
- set "DefPS1=Set-MpPreference -SignatureFallbackOrder %DefSig%; Set-MpPreference -DisableBehaviorMonitoring $t;"
- set "DefPS2=Set-MpPreference -DisableIOAVProtection $t; Set-MpPreference -DisableRealtimeMonitoring $t;"
- if defined DEF powershell -c "$t=%toggle%; %DefPS1%; %DefPS2%;"
- :: done, update context-menu icon
- reg add HKCR\DesktopBackground\shell\HushWindows /v Icon /d "ieframe.dll,%icon%" /f >nul 2>nul
- exit/b
- :choices %1:title %2:all_choices %3:def_choices %4:output_variable GUI dialog with autosize checkboxes - outputs %CHOICES%
- setlocal &set "parameters=$n='%~1'; $all='%~2'; $def='%~3'; $p='HKCU:\Environment'; $pad=32;"
- set "s1=[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); $f=New-Object System.Windows.Forms.Form;"
- set "s2=[void][System.Reflection.Assembly]::LoadWithPartialName('System.Drawing'); $f.Forecolor='Black';$f.BackColor='WhiteSmoke';"
- set "s3=$r=(Get-ItemProperty $p).$n; if($r -ne $null){$opt=$r.split(',')}else{$opt=$def.split(',')}; function CLK(){ $v=@();"
- set "s4=foreach($x in $cb){if($x.Checked){$v+=$x.Text}}; New-ItemProperty -Path $p -Name $n -Value $($v -join ',') -Force };"
- set "s5=$BCLK=@(0, {CLK}, {foreach($z in $cb){$z.Checked=$false;if($def.split(',') -contains $z.Text){$z.Checked=$true}};CLK});"
- set "s6=$i=1; $cb=foreach($l in $all.split(',')){$c=New-Object System.Windows.Forms.CheckBox; $c.Name='c$i'; $c.AutoSize=$true;"
- set "s7=$c.Text=$l; $c.Location=New-Object System.Drawing.Point(($pad*2.5),(16+(($i-1)*24))); $c.BackColor='Transparent';"
- set "s8=$c.add_Click({CLK}); $f.Controls.Add($c); $c; $i++; }; foreach($s in $cb){if($opt -contains $s.Text){$s.Checked=$true}};"
- set "s9=$j=1; $bn=@('OK','Reset');foreach($t in $bn){ $b=New-Object System.Windows.Forms.Button; $b.BackColor='Transparent';"
- 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';"
- set "s11=$b.add_Click($BCLK[$j]); if ($t -eq 'OK'){$b.DialogResult=1;$f.AcceptButton=$b}; $b.Name='b$j'; $b.Text=$t;"
- set "s12=$f.Controls.Add($b);$j++;}; $f.Text=$n; $f.FormBorderStyle='Fixed3D'; $f.AutoSize=$true; $f.AutoSizeMode='GrowAndShrink';"
- set "s13=$f.MaximizeBox=$false; $f.StartPosition='CenterScreen'; $f.Add_Shown({$f.Activate()}); $ret=$f.ShowDialog();"
- set "s14=if ($ret -ne 1) {Remove-ItemProperty -Path $p -Name $n -Force -erroraction 'silentlycontinue' | out-null}"
- set "s15=else {write-host (Get-ItemProperty -Path $p -Name $n).$n;}"
- for /l %%# in (1,1,15) do call set "ps_Choices=%%ps_Choices%%%%s%%#:"=\"%%"
- for /f "usebackq tokens=* delims=" %%# in (`powershell -c "%parameters% %ps_Choices%"`) do set "choices_var=%%#"
- endlocal & set "%~4=%choices_var%" & exit/b &rem snippet by AveYo released under MIT License
- :reg_query %1:KeyName %2:ValueName %3:OutputVariable %4:other_options[example: /t REG_DWORD]
- 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:*) =%%"
- endlocal & set "%~3=%rv%" & exit/b AveYo: call :reg_query "HKCU\MyKey" "MyValue" MyVar
- :needs_admin_rights
- color 0c&echo. &echo PERMISSION DENIED! Right-click %~nx0 ^& Run as administrator &timeout /t 60 &color 0f&title %COMSPEC% &exit/b
- :context_menu_windowless_toggle */
- if (WSH.Arguments(0)=='M') WSH.CreateObject('Shell.Application').ShellExecute('schtasks.exe','/Run /TN HushWindows','','',0);
- else WSH.CreateObject('Shell.Application').ShellExecute('cmd.exe','/c call "'+WSH.ScriptFullName+'" T','','',0);
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement