triviet4

Help Me, Please with code ProcessClose on Windows

7 posts in this topic

I have code ProcessClose 1 File when press Hot key

HotKeySet("{F6}","exitt")

Do
ToolTip("test",0,0)
Until 0

Func exitt()
ProcessClose ("File.exe")
EndFunc

Please, help me, with code ProcessClose all File running on windows but may except for 1,2 Process when press Hot key

 

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

#4 ·  Posted (edited)

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

 


Regards,
 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Try running with Adminstrator.
The game was too big I can not download and run the test. (Maximum download speed is 400KB/s)

#RequireAdmin

 


Regards,
 

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