Run through admin rights
(including <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> )
I use the list of processes in List<string> - Processes that do not need to kill.
var name = new List<string> { "svchost", "csrss", "System", "wininit","ApplicationFrameHost", "irstrtsv","scrncap","lsass","devenv","System","audiodg","fontdrvhost", "wininit","taskmgr","dwm","spoolsv","smss","alg","igfxTray","IpOverUsbSvc", "SearchIndexer","lsm","taskhost","svchost","explorer","scrncap","opera", "winlogon","services","conhost","ctfmon","ati2evxx","BTTray","nvcontainer", "dwm","issch","jusched","rthdcpl","rundll32","wmiprvse","wudfhost","SwiService", "AvrcpService","devenv","msvsmon","LMS","jhi_service","nvvsvc","nvcontainer", "igfxHK","igfxEM","igfxCUIService","IAStorDataMgrSvc","PerfWatson2","PresentationFontCache", "SecurityHealthService","ShellExperienceHost","sihost","SynTPEnh","SynTPEnhService","SynTPHelper", "SystemSettings","taskhostw","ViakaraokeSrv","WinStore.App","WUDFHost", }; try { foreach (var anti in Process.GetProcesses()) { if (name.IndexOf(item: anti.ProcessName.ToLower()) < 0 && anti.ProcessName != Process.GetCurrentProcess().ProcessName) { // Обходим все процессы из List<string> и убиваем все остальные. anti.Kill(); } } } catch (Exception ex) { File.WriteAllText("ErrorEx.txt", contents: ex.Message); } After launching, at most one process is killed from the list.
Run on Windows 10.
PS: ErrorEx.txt - Access is denied!
What is he missing :)?