How-to Emulate the TOP command in Windows

On April 6, 2011, in How-to, Scripting, by Cubert aka (Cube Dweller)

Top is a Linux process that shows a list of processes running on the system and what levels of resources are being used. This application provides all processes running, the CPU and Memory consumed and with several switches available you can see things like the location of the executable that is running.

Unfortunately, they don’t make a TOP executable ported for Microsoft Windows but don’t despair.   You can use Power Shell to script a simple TOP style display that operates just like TOP on a Linux system.

 

Here is the one liner you need to get a top style process viewer running on windows.

while (1) { ps | sort -desc cpu | select -first 30; sleep -seconds 2; cls }

 

Copy the above line and paste it in to your Power Shell console. You should see something similar to the following image.

Tagged with:
 

7 Responses to “How-to Emulate the TOP command in Windows”

  1. Mahfooz says:

    Can u explain this in a little more detail like what is the exact information being displayed in each column here and can I write the results to some text file and can this command be configured to execute after a given interval automatically

  2. Mahfooz says:

    Can u explain this in a little more detail like what is the exact information being displayed in each column here and can I write the results to some text file and can this command be configured to execute after a given interval automatically

  3. After the first refresh the title row disappears, how do we pin it?

  4. […] of these variations of top were designed to run on Unix-like systems, but there is an equivalent in Windows as well (just significantly less elegant in execution.) Here is top running on the Raspberry Pi I […]

  5. gerard says:

    This is NOT a top emulation. The CPU information returned by get-process is the TOTAL time for a process since the system start. The top command give the current CPU load. Top is much more useful than this one liner.

  6. While ($true) {
    Get-Process | Sort-Object -Descending cpu | Select-Object -First 30 | Format-Table -AutoSize
    Start-Sleep -Seconds 2
    Clear-Host
    }

Leave a Reply