Pidof is a lightweight command-line utility for retrieving process IDs (PIDs) based on image names or window titles. It provides a simple way to list running processes along with their PIDs and memory usage.
pidof [<filename>...[--title/-t <title>]] [--help/-h] [--nobanner/-n]-h, --help→ Display the help menu.-n, --nobanner→ Suppress the banner.-t, --title→ Search for processes by window title instead of filename.<filename>→ Specify the process filename(s) to find the PID.
pidof notepad.exe
pidof --title "Untitled - Notepad"
pidof notepad.exe --nobannerThis tool is part of the 8gudbitsKit project. To download the executable for Windows, visit the 8gudbitsKit repository.
- Uses Windows built-in
tasklistcommand to fetch process details. - Filters results based on either image name (
IMAGENAME eq <filename>) or window title (WINDOWTITLE eq <title>). - Executes the command using
_popen()to capture output dynamically.
- The output from
tasklistis in CSV format, which is split into lines using a customsplit()function. - Each line is further broken into columns, extracting PID, memory usage, and image name.
- The
trimQuotes()function removes unnecessary quotes from CSV fields for clean output.
- Uses
std::setw()to align columns properly for readability. - Displays PID first, followed by memory usage, then image name.
- Ensures a structured table-like format for easy scanning.
- Supports multiple filenames and titles via command-line arguments.
- Flags like
--title,--nobanner, and--helpare processed dynamically.
- Displays a banner unless suppressed with
--nobanner. - Provides a structured help menu when
--helpis invoked.
This ensures efficient process lookup while maintaining a clean and readable output format.