Task Manager is a C++ program that displays and manages processes running on your system. The program interacts with the tasklist
command to retrieve and parse details about active processes, including:
- Image Name
- PID (Process ID)
- Session Name
- Session ID
- Memory Usage
- Display all running processes.
- Sort processes by:
- Image Name
- PID
- Session Number
- Memory Usage
- Filter processes by session name (e.g., Console or Services).
- Exit the program gracefully.
The program uses the tasklist
command to generate a CSV file of processes, parses the file to extract process details, and provides sorting and filtering options to the user.
Compile the program and execute it:
g++ -o TaskManager TaskManager.cpp
./TaskManager
When the program runs, you'll see the following menu:
Choose:
1) Display Processes.
2) Display Sorted Processes by Image Name.
3) Display Sorted Processes by PID.
4) Display Sorted Processes by Session Number.
5) Display Sorted Processes by Memory Usage.
6) Display Filtered Processes by Session Name.
7) Exit Program.
Enter your choice to interact with the program:
- Option 1: Display all processes.
- Option 2-5: View sorted processes.
- Option 6: Filter processes by session name (
Console
orServices
). - Option 7: Exit the program.
Here’s an example of the program’s output when displaying processes:
The Processes are:
Image Name PID Session Name Session# Mem Usage
======================== ======== ================ =========== ============
System Idle Process 0 Services 0 8 K
System 4 Services 0 3,300 K
Registry 224 Services 0 78,420 K
smss.exe 712 Services 0 1,328 K
csrss.exe 1028 Services 0 8,060 K
wininit.exe 1128 Services 0 8,780 K
csrss.exe 1140 Console 1 9,276 K
-
TaskManager
Class: Manages all process-related operations.displayProcess()
: Displays all processes.sortedByImageName()
: Sorts by image name alphabetically.sortedByPID()
: Sorts by Process ID.sortedBySessionNumber()
: Sorts by session number.sortedByMemoryUsage()
: Sorts by memory usage (numerical).filterSessionName()
: Filters processes by session name.
-
Helper Functions:
convertMemoryUsage()
: Converts memory usage strings to integers for sorting.splitWords()
: Parses CSV file lines to extract process details.
The program uses:
<bits/stdc++.h>
for standard C++ libraries.tasklist
command (Windows).
- Operating System: Windows
- Compiler: g++
- The program relies on the
tasklist
command, so ensure it's available in your environment.
Contributions are welcome! If you'd like to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-name
). - Commit your changes (
git commit -m 'Add feature name'
). - Push to the branch (
git push origin feature-name
). - Create a pull request.
- Name: Mohammed Atef Abd El-Kader
- ID: 20231143
- Version: 3.0
- Date: 25 Nov 2024
This project is licensed under the MIT License. See the LICENSE file for details.