Jump to content
triviet4

Help Me, Please with code ProcessClose on Windows

Recommended Posts

Welcome to AutoIt and the forum!
Please have a look at function ProcessList. Loop through the array and close all processes but the 1, 2.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

i cann't unknown ProcessList. At a time Turn on Computer, i will be different ProcessList

As well as With shorcut:

taskkill /F /FI "USERNAME eq user_name" /FI "IMAGENAME ne explorer.exe" /FI "IMAGENAME ne dwm.exe"

 

Edited by triviet4

Share this post


Link to post
Share on other sites

I found this code. It's wrong or right + How add Hotkey

Local $sProcessList = ProcessList()
For $i=0 To UBound($sProcessList)-1
    CloseProcess($sProcessList[$i][0])
Next

Func CloseProcess($sProcess)
    Local $sListProcessSystem=StringSplit("smss.exe|csrss.exe|wininit.exe|services.exe|lsass.exe|svchost.exe|spoolsv.exe|MsMpEng.exe|NisSrv.exe|dasHost.exe|SearchIndexer.exe|OSPPSVC.EXE|audiodg.exe|winlogon.exe|dwm.exe|taskeng.exe|sihost.exe|taskhostw.exe|RuntimeBroker.exe|ShellExperienceHost.exe|SearchUI.exe|SettingSyncHost.exe|SearchProtocolHost.exe|WUDFHost.exe|InstallAgent.exe|WmiPrvSE.exe|HxTsr.exe|SearchFilterHost.exe|rundll32.exe|", "|")
    For $x=0 To UBound($sListProcessSystem)-1
        If Not StringInStr($sProcess,$sListProcessSystem[$x]) Then
            ConsoleWrite("ProcessClose: " & $sProcess&@CRLF)
            ProcessClose($sProcess)
        EndIf
    Next
EndFunc

 

Edited by triviet4

Share this post


Link to post
Share on other sites
Opt("TrayAutoPause", 0)

HotKeySet("{F6}", "CloseProcess")
HotKeySet("{F7}", "_Exit")

While 1
    Sleep(10)
    ToolTip("F6: CloseProcess - F7: Exit", @DesktopWidth / 2, @DesktopHeight / 2, "", 2, 2)
WEnd

Func CloseProcess()
    Local $sProcessList = ProcessList()
    For $i = 0 To UBound($sProcessList) - 1
        _CloseProcess($sProcessList[$i][0])
    Next
EndFunc   ;==>CloseProcess

Func _CloseProcess($sProcess)
    Local $sListProcessSystem = StringSplit(@ScriptName & "|AutoIt3.exe|SciTE.exe|dllhost.exe|UniKey.exe|explorer.exe|smss.exe|csrss.exe|wininit.exe|services.exe|lsass.exe|svchost.exe|spoolsv.exe|MsMpEng.exe|NisSrv.exe|dasHost.exe|SearchIndexer.exe|OSPPSVC.EXE|audiodg.exe|winlogon.exe|dwm.exe|taskeng.exe|sihost.exe|taskhostw.exe|RuntimeBroker.exe|ShellExperienceHost.exe|SearchUI.exe|SettingSyncHost.exe|SearchProtocolHost.exe|WUDFHost.exe|InstallAgent.exe|WmiPrvSE.exe|HxTsr.exe|SearchFilterHost.exe|rundll32.exe", "|")
    Local $sTrue = False
    For $x = 0 To UBound($sListProcessSystem) - 1
        If $sProcess = $sListProcessSystem[$x] Then $sTrue = True
    Next
    If Not $sTrue Then
        ConsoleWrite("ProcessClose: " & $sProcess & @CRLF)
        ToolTip("ProcessClose: " & $sProcess, @DesktopWidth / 2, @DesktopHeight / 2, "", 2, 2)
        ProcessClose($sProcess)
    EndIf
EndFunc   ;==>_CloseProcess

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

Share this post


Link to post
Share on other sites

Code of "Trong" is good. Thank's very much

But when i play game CrossFire, FPS game fullscreen, code didn't

I have Alt+tab, code can do that (ProcessClose game)

How fix it. Help me, Please

Edited by triviet4

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...