Skip to content

Batch Script Process: Viewing, Killing, and Starting Processes in Windows

Learn how to use Windows Batch Script commands like tasklist, taskkill, and start to manage processes, including listing running tasks, terminating specific processes, and launching new applications with custom priority settings.

Batch Script Process Management

Windows Batch Script provides several commands for managing processes: tasklist to view running processes, taskkill to terminate processes, and start to launch new applications. This article covers these commands in detail with practical examples.


Viewing Running Processes with tasklist

The tasklist command displays all currently running processes on the local or a remote computer, including details like Process ID (PID), session information, and memory usage.

Syntax

tasklist [/s system [/u username [/p password]]] [/m [module] | /svc | /v] [/fi filter] [/fo format] [/nh]

Options

Option Description
/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.
/m [module] Lists all tasks currently using the given exe/dll name. If module name is not specified, all loaded modules are displayed.
/svc Displays services hosted in each process.
/v Displays verbose task information.
/fi filter Displays a set of tasks that match a given criteria specified by the filter.
/fo format Specifies the output format. Valid values: TABLE, LIST, CSV.
/nh Specifies that the column header should not be displayed. Valid only for TABLE and CSV formats.

Examples

List all processes on the local system:

tasklist

Output:

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0 Services           0          4 K
System                          4 Services           0          272 K
smss.exe                       344 Services           0          1,040 K
csrss.exe                      528 Services           0          3,892 K
wininit.exe                    620 Services           0          3,528 K

List all processes in CSV format:

tasklist /fo CSV

List all processes using a specific DLL:

tasklist /m kernel32.dll

List all services running in each process:

tasklist /svc

List processes with verbose information:

tasklist /v

List processes without column headers:

tasklist /nh

Terminating Processes with taskkill

The taskkill command allows you to terminate running processes by process ID (PID) or image name.

Syntax

taskkill [/s system [/u username [/p password]]] {[/fi filter] [/pid processid | /im imagename]} [/f] [/t]

Options

Option Description
/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.
/pid processid Specifies the Process ID of the process to be terminated.
/im imagename Specifies the image name of the process to be terminated. Wildcards (* or ?) can be used to specify all image names.
/f Specifies to forcefully terminate the process(es).
/t Terminates the specified process and any child processes started by it.
/fi filter Applies a filter to select one or more processes.

Examples

Forcefully terminate all instances of Notepad:

taskkill /f /im notepad.exe

Terminate a process with PID 1234:

taskkill /pid 1234

Terminate a process and all its child processes:

taskkill /f /t /pid 1234

Terminate all processes using more than 100MB of memory:

taskkill /f /fi "MEMUSAGE gt 102400"

Terminate all processes with a specific window title:

taskkill /f /fi "WINDOWTITLE eq Untitled - Notepad"

Starting New Processes with start

The start command launches a new window to run a specified program or command.

Syntax

start "title" [/d path] [options] "command" [parameters]

Parameters

Parameter Description
title Text for the CMD window title bar. If omitted, the command is used as the title.
/d path Specifies the starting directory.
command The command, batch file, or executable program to run.
parameters Parameters or switches for the command.

Options

Option Description
/min Starts the window minimized.
/max Starts the window maximized.
/low Runs the process with IDLE priority.
/normal Runs the process with NORMAL priority (default).
/abovenormal Runs the process with ABOVENORMAL priority.
/belownormal Runs the process with BELOWNORMAL priority.
/high Runs the process with HIGH priority.
/realtime Runs the process with REALTIME priority. Use with extreme caution.
/wait Waits for the started program to exit before continuing.
/b Starts the application without creating a new window.

Examples

Start Notepad in a new window:

start notepad.exe

Start a minimized window with a custom title:

start "My Notepad" /min notepad.exe

Open a file in Microsoft Word:

start "" "C:\Program Files\Microsoft Office\Winword.exe" "D:\Documents\report.docx"

Start a process with high priority:

start "" /high myapp.exe

Start a process in a specific directory:

start "" /d "C:\Program Files\MyApp" myapp.exe

Start a batch file and wait for it to complete:

start "" /wait backup.bat

Start an application without showing a window:

start "" /b background_task.exe

Summary

These three commands provide comprehensive process management in Windows Batch Script:

Command Purpose Key Features
tasklist View running processes Displays PID, memory usage, session info, supports filters
taskkill Terminate processes Kill by PID or name, force kill, kill child processes
start Launch new processes Custom window states, priority levels, working directories

With these commands, you can create powerful batch scripts to monitor, control, and launch processes on your Windows system. Always test your scripts thoroughly, especially when terminating processes, to avoid accidental system disruption.

Navigation