我们的一位读者问我们:“如何从任务管理器(Task Manager)打印正在运行的进程列表?”。答案是……您不能从Task Manager执行此操作,甚至在Windows 10中也不行。为了打印这样的列表,您需要使用命令提示符(Command Prompt)或PowerShell并运行一些命令来生成正在运行的进程列表,然后您可以像打印文档一样打印它。让我们看看它是如何工作的:
注意:(NOTE:)本指南适用于Windows 10、Windows 8.1 和Windows 7。
如何从命令提示符打印正在运行的进程列表(Command Prompt)
启动命令提示符(Command Prompt)并使用以下命令:tasklist > "path to file"。tasklist命令显示(tasklist)Windows 计算机(Windows computer)上运行的所有任务的应用程序和服务列表。使用的参数指定保存此列表的文本文件。(text file)我想将列表保存在我的 D 驱动器上名为processes.txt的文件中,所以我输入:tasklist > "D:processes.txt"。选择要保存文件的路径时,请确保它是您的用户帐户(user account)可以访问的位置。
如果您在打开命令提示符(Command Prompt)时需要一些帮助,请阅读本指南:在Windows中启动(Windows)命令提示符(Command Prompt)的 7 种方法。
当您在记事本(Notepad)中打开输出文件时,您会看到它的格式如下面的屏幕截图所示。数据被放置在一个包含以下列的表中:图像名称(Image Name)、PID(进程 ID)、会话名称(Session Name)、Session#(# 代表数字)和内存使用情况(Mem Usage)(内存使用情况)。
显然,此命令具有可用于格式化其输出的参数。完整的文档可以在Microsoft的TechNet 网站上(TechNet website)找到:Tasklist。不要犹豫,阅读并自行尝试。
如何从PowerShell打印正在运行的进程列表(PowerShell)
PowerShell是一个更复杂的命令行工具,允许对其输出进行更多自定义。使用的基本命令是:get-process或gps(它的简短版本)。
要将其输出发送到文本文件(text file),您需要编写get-process | out-file "path to file"或gps | out-file "path to file"。我想将列表保存在我的 D 驱动器上名为process.txt的文件中,所以我输入:get-process | out-file "D:process.txt"。你可以看到这个命令以及它的短版本替代(short-version alternative),在下面的PowerShell 窗口中(window below)键入。选择要保存文件的路径时,请确保它是您的用户帐户(user account)可以访问的位置。
如果您在启动PowerShell时需要帮助,请不要犹豫,阅读这篇文章:什么是PowerShell以及您可以用它做什么?。
输出文本文件(output text file)的格式如下所示,它包括以下列:
- 句柄(Handles)- 进程已打开的句柄数。
- NPM(K) - 进程正在使用的非分页内存量,以千字节为单位。
- PM(K) - 进程正在使用的可分页内存量,以千字节为单位。
- WS(K) - 进程工作集的大小,以千字节为单位。工作集由进程最近引用的内存页组成。
- CPU(s) -进程在所有处理器上使用的处理器时间量,以秒为单位。(processor time)
- Id - 正在运行的进程的进程 ID ( PID )。
- SI - 不幸的是,我们找不到该专栏及其共享数据的任何文档。
- ProcessName - 正在运行的进程的名称。
如您所见,输出比使用命令提示符(Command Prompt)时更复杂。此外,还有更多选项可以自定义输出。我建议您阅读以下文档:Get-Process(获取机器上运行的进程列表)、Out-File(将输出发送到文件)和Out-Printer(将输出发送到打印机)。
结论
我们希望您发现本教程对您有用。如果您知道打印在Windows(Windows)中运行的进程列表的其他方法,请不要犹豫,使用下面的评论表分享它们。
How to print the list of running processes in Windows -
One of our readers asked us: “How do you print the list of running processes from Task Manager?”. Unfortunately, you can’t do this from Task Manager. However, you can run some commands to generate a list of running processes in Windows and then print it like you would print a standard document. Here’s how it all works, using only the tools built into Windows:
NOTE: This guide applies to all versions of Windows, including Windows 10 and Windows 11.
How to print the list of running processes using the tasklist command (in CMD, PowerShell, or Windows Terminal)
The tasklist command can output the list of active processes to a text file on your PC, which you can then print easily. You can run this command in any command-line environment you prefer: Command Prompt, PowerShell, or Windows Terminal.
Simply open the Command Prompt (or one of the other two) and type:
Replace path to file with the actual path towards the file you want to create on your disk with the list of running processes. Then, press Enter on your keyboard. I wanted to save the list in a file named processes.txt on my D drive, so I typed:
Running the tasklist command
Open File Explorer and navigate to the path you specified for your file. Double-click on the file to open it. It should display data similar to the screenshot below. The list of running processes is placed in a table with the following columns: Image Name (the name of the process), PID (Process ID), Session Name, Session# (# stands for Number), and Mem Usage (Memory Usage).
The output of the tasklist command
Feel free to print (press CTRL+P) the list of active processes using your default printer.
NOTE: The tasklist command has many parameters you can use to format its output. Complete documentation can be found on Microsoft’s TechNet website: Tasklist. Don’t hesitate to read it and experiment on your own.
How to print the list of running processes using the Get-Process command (in PowerShell or Windows Terminal)
There’s another command you can use, but only in PowerShell and Windows Terminal. It is named get-process or gps (the short version). To use this command, open PowerShell (or a PowerShell tab in Windows Terminal) and type the following:
or
I wanted to save the list in a file named process.txt on my D drive, so I typed:
or
Running the get-process command in PowerShell
The output file is formatted, and it includes the following columns:
- Handles - the number of handles that the process has opened.
- NPM(K) - the amount of non-paged memory that the process is using, in kilobytes.
- PM(K) - the amount of pageable memory that the process is using, in kilobytes.
- WS(K) - the size of the process's working set in kilobytes. It consists of the pages of memory that were recently referenced by the process.
- CPU(s) - the amount of processor time that the process has used on all processors in seconds.
- Id - the process ID (PID) of the process that is running.
- SI - the session ID of the process.
- ProcessName - the name of the process.
The output of the get-process command
You can now easily print the list of running processes from Notepad or any other app you used to open the file containing the processes list.
NOTE: As you can see, the output of the get-process command is more complex than what you get from tasklist. Also, there are more options available to customize it. Therefore, I recommend you to read the following documentation: Get-Process (Get a list of processes running on a machine), Out-File (Send output to a file), and Out-Printer (Send output to a printer).
How to print the list of running processes using WMIC (in CMD, PowerShell, or Windows Terminal)
WMIC or Windows Management Instrumentation Command line is a software utility that allows users to perform Windows Management Instrumentation (WMI) operations from any command-line environment (Command Prompt, PowerShell, or Windows Terminal). You can use it for many tasks, including saving a list with all running processes in a text file that you can print. To do that, open any command-line environment you want in Windows. We’ve chosen to start Windows Terminal. Next, type this command:
Replace path to file with the actual path towards the file you want to create, and then press Enter on your keyboard.
Running the wmic command in Windows Terminal
I wanted to save the list of running processes in a file named process.txt on my D drive, so I typed:
The resulting file looks similar to the screenshot below and the information is split into the following columns:
- HandleCount - the number of operating system handles that the process has opened.
- Name - the name of each running process.
- Priority - the priority assigned by Windows to each process. The higher the number, the higher the priority.
- Process ID - the ID of the process, as assigned by Windows.
- ThreadCount - the operating system threads currently running in the associated process.
- WorkingSetSize - the total amount of physical memory each process is using, in bytes.
The output you get from wmic
For more information about the properties of each process, read this documentation from Microsoft: Win32_Process class.
How did you print the list of running processes?
I hope that you’ve found this tutorial helpful and you’ve managed to print the list of processes running on your Windows computer or device. Before closing, let us know in a comment which command you prefer and why. Also, if you know other methods for printing a list of the processes that are running in Windows, don't hesitate to share them.