Last active
January 25, 2026 19:40
-
-
Save andreydjason/f86a645e0f50772604aecb3e875b1ee3 to your computer and use it in GitHub Desktop.
Auto Stop Programs & Services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Users\andre\Documents\WindowsPowerShell\stop-all.ps1" | |
| echo. echo Concluido. Feche esta janela manualmente quando desejar. pause endlocal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Salve como stop_things.ps1 e execute em PowerShell como Administrador | |
| param( | |
| [switch]$Run | |
| ) | |
| $Run = $true | |
| $processes = @( | |
| "DataExchangeHost.exe", | |
| "RuntimeBroker.exe", | |
| "backgroundTaskHost.exe", | |
| "LockApp.exe", | |
| "wlanext.exe", | |
| "MicrosoftEdgeUpdate.exe", | |
| "MpCmdRun.exe", | |
| "WmiPrvSE.exe", | |
| "CrossDeviceResume.exe", | |
| "setup.exe", | |
| "WmiPrvSE.exe", | |
| "WMIADAP.exe", | |
| "WmiPrvSE.exe" | |
| ) | |
| $services = @( | |
| "DsmSvc", | |
| "PCManager Service Store", | |
| "NPSMSvc_75e2f", | |
| "WFDSConMgrSvc", | |
| "CortexLauncherService", | |
| "Razer Game Manager Service 3", | |
| "RzActionSvc", | |
| "CDPUserSvc_75e2f", | |
| "CDPUserSvc_88035", | |
| "OneSyncSvc_88035", | |
| "OneSyncSvc_9d33a", | |
| "OneSyncSvc_b129a", | |
| "WdiServiceHost", | |
| "DoSvc", | |
| "StiSvc", | |
| "DevicesFlowUserSvc_9d33a", | |
| "DevicesFlowUserSvc_b129a", | |
| "DevicesFlowUserSvc_75e2f", | |
| "CDPUserSvc_b129a", | |
| "HidHideWatchdog.exe", | |
| "PCManager Service Store", | |
| "CDPUserSvc_9d33a", | |
| "WFDSConMgrSvc", | |
| "NPSMSvc_9d33a", | |
| "DeviceAssociationService", | |
| "InstallService", | |
| "MDCoreSvc", | |
| "wuauserv" | |
| ) | |
| Write-Host "Data:" (Get-Date) | |
| if ($Run) { Write-Host "MODO: executando..." } else { Write-Host "MODO: dry-run (apenas exibindo acoes)" } | |
| Write-Host "----------------------------------------" | |
| foreach ($s in $services) { | |
| try { | |
| $svc = Get-Service -Name $s -ErrorAction Stop | |
| if ($svc.Status -eq 'Running') { | |
| if ($Run) { | |
| Write-Host "Parando servico (ServiceName): $s ..." | |
| Stop-Service -Name $s -Force -ErrorAction Stop | |
| Write-Host "[OK] Parada solicitada: $s" | |
| } else { | |
| Write-Host "[DRY] Pararia servico (ServiceName): $s" | |
| } | |
| } else { | |
| Write-Host "[INFO] Servico $s nao esta em execucao (Status: $($svc.Status))" | |
| } | |
| } catch { | |
| try { | |
| $matches = Get-CimInstance Win32_Service | Where-Object { | |
| ($_.DisplayName -and $_.DisplayName -like "*$s*") -or ($_.PathName -and $_.PathName -like "*$s*") | |
| } | |
| if ($matches) { | |
| foreach ($m in $matches) { | |
| if ($m.State -eq 'Running') { | |
| if ($Run) { | |
| Write-Host "Parando servico: $($m.Name) (mapeado por '$s') ..." | |
| Stop-Service -Name $m.Name -Force -ErrorAction Stop | |
| Write-Host "[OK] Parada solicitada: $($m.Name)" | |
| } else { | |
| Write-Host "[DRY] Pararia servico: $($m.Name) (mapeado por '$s')" | |
| } | |
| } else { | |
| Write-Host "[INFO] Servico $($m.Name) (mapeado por '$s') nao esta em execucao (State: $($m.State))" | |
| } | |
| } | |
| } else { | |
| Write-Host "[AVISO] Nenhum servico encontrado relacionado a '$s'" | |
| } | |
| } catch { | |
| Write-Host "[ERRO] Ao procurar/parar servico relacionado a '$s': $($_.Exception.Message)" | |
| } | |
| } | |
| } | |
| Write-Host "----------------------------------------" | |
| foreach ($p in $processes) { | |
| try { | |
| $procs = Get-Process -Name ([System.IO.Path]::GetFileNameWithoutExtension($p)) -ErrorAction Stop | |
| if ($Run) { | |
| foreach ($pr in $procs) { | |
| Write-Host "Encerrando processo: $($pr.ProcessName) (Id $($pr.Id)) ..." | |
| Stop-Process -Id $pr.Id -Force -ErrorAction Stop | |
| Write-Host "[OK] Processo encerrado: $($pr.ProcessName) (Id $($pr.Id))" | |
| } | |
| } else { | |
| Write-Host "[DRY] Encerraria processo: $p" | |
| } | |
| } catch { | |
| Write-Host "[INFO] Processo $p nao em execucao ou erro: $($_.Exception.Message)" | |
| } | |
| } | |
| Write-Host "Concluido. Feche esta janela manualmente quando desejar." | |
| if (-not $Host.UI.RawUI.KeyAvailable) { Read-Host "Pressione Enter para fechar" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment