Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 06, 2016, 10:09:18 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Help with AutoHotkey to Terminate Process  (Read 10497 times)

jdd

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 214
    • View Profile
    • Donate to Member
Help with AutoHotkey to Terminate Process
« on: April 30, 2006, 09:18:00 PM »
I have tried to write a script but without any luck.  Can someone help me write an ahk to do the following in Windows XP?

1. Press Control-Alt-Del to open the Windows Task Manager
2. Go to the 'Processes' tab
3. Select the program called "stupidprogram.exe"
4. Click 'End Process' button
5. Close Application

Thanks,
jdd

kimmchii

  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 360
    • View Profile
    • Donate to Member
Re: Help with AutoHotkey to Terminate Process
« Reply #1 on: April 30, 2006, 10:17:29 PM »
you can use taskkill.exe in a batch file:

if it is a service, use NET STOP "name" in the batch file.


TASKKILL [/S system [/U username [/P [password]]]]
         { [/FI filter] [/PID processid | /IM imagename] } [/F] [/T]

Description:
    This command line tool can be used to end one or more processes.
    Processes can be killed by the process id or image name.

Parameter List:
    /S    system           Specifies the remote system to connect to.

    /U    [domain\]user    Specifies the user context under which
                           the command should execute.

    /P    [password]       Specifies the password for the given
                           user context. Prompts for input if omitted.

    /F                     Specifies to forcefully terminate
                           process(es).

    /FI   filter           Displays a set of tasks that match a
                           given criteria specified by the filter.

    /PID  process id       Specifies the PID of the process that
                           has to be terminated.

    /IM   image name       Specifies the image name of the process
                           that has to be terminated. Wildcard '*'
                           can be used to specify all image names.

    /T                     Tree kill: terminates the specified process
                           and any child processes which were started by it.

    /?                     Displays this help/usage.

Filters:
    Filter Name   Valid Operators           Valid Value(s)
    -----------   ---------------           --------------
    STATUS        eq, ne                    RUNNING | NOT RESPONDING
    IMAGENAME     eq, ne                    Image name
    PID           eq, ne, gt, lt, ge, le    PID value
    SESSION       eq, ne, gt, lt, ge, le    Session number.
    CPUTIME       eq, ne, gt, lt, ge, le    CPU time in the format
                                            of hh:mm:ss.
                                            hh - hours,
                                            mm - minutes, ss - seconds
    MEMUSAGE      eq, ne, gt, lt, ge, le    Memory usage in KB
    USERNAME      eq, ne                    User name in [domain\]user
                                            format
    MODULES       eq, ne                    DLL name
    SERVICES      eq, ne                    Service name
    WINDOWTITLE   eq, ne                    Window title

NOTE: Wildcard '*' for the /IM switch is accepted only with filters.

NOTE: Termination of remote processes will always be done forcefully
      irrespective of whether /F option is specified or not.

Examples:
    TASKKILL /S system /F /IM notepad.exe /T
    TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
    TASKKILL /F /IM notepad.exe /IM mspaint.exe
    TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
    TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
    TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
    TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"
If you find a good solution and become attached to it, the solution may become your next problem.
~Robert Anthony

wr975

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 369
    • View Profile
    • Donate to Member
Re: Help with AutoHotkey to Terminate Process
« Reply #2 on: May 01, 2006, 02:45:32 AM »
I have tried to write a script but without any luck.  Can someone help me write an ahk to do the following in Windows XP?

1. Press Control-Alt-Del to open the Windows Task Manager
2. Go to the 'Processes' tab
3. Select the program called "stupidprogram.exe"
4. Click 'End Process' button
5. Close Application

Thanks,
jdd

Try the command "process" to kill a task.

http://www.autohotke...commands/Process.htm

Example

process,close,stupidprogram.exe
« Last Edit: May 01, 2006, 02:48:23 AM by wr975 »

jdd

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 214
    • View Profile
    • Donate to Member
Re: Help with AutoHotkey to Terminate Process
« Reply #3 on: May 01, 2006, 07:01:54 AM »
Thanks wr975!  That did the trick.

jdd

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: Help with AutoHotkey to Terminate Process
« Reply #4 on: May 01, 2006, 07:04:43 AM »
@jdd: Sorry for the late response, but i forgot this had already been done. See the code of ProcessKiller. It does exactlly what you're looking for.

jdd

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 214
    • View Profile
    • Donate to Member
Re: Help with AutoHotkey to Terminate Process
« Reply #5 on: May 01, 2006, 07:14:05 AM »
In this particular case, it involves a mailchecker program (Mailwasher) that I always have running on my system.  However, periodically, it disappears from the Windows tray so I have to kill it before I can re-start it to use it again.

Thanks,
jdd