Windows Guides Feed

No matter how much money you have invested in a new computer, sooner or later you will face performance problems.

These problems are usually related with the CPU or the memory. Computers are becoming so complex that you need all the help you can get to find the source of the problems.

The first thing I do when I notice that my computer is not acting as it should is run Task Manager. With this tool you can easily see the usage of Memory and CPU of every process on your computer. I always do the same: look for the processes that are using more CPU and see if there are enough physical memory available.

So, why not have a utility that do the same with just one click and that can be easily found in your Windows 7 Taskbar?

To do this we are going to use one component of Windows 7, PowerShell, that can be also used in other Windows versions.

PowerShell is an enhancement of VBScript, which is no more than a scripting language.

Even if you don’t understand what a scripting language is, you can just read this post and you will have your utility running for free in no time.

The information this utility is going to display is the following:

The first list is of every process that is using more than 0 percent of your CPU. This list is sorted by the CPU usage at the moment it’s run. In this case the _Total and the Idle process are not real processes; however, WmiPrvSE is a real process which is using 3% CPU.

The second list displays the 5 running processes that have used more CPU Time. This is measured in seconds. If the computer is running slowly since startup, this is the list you need to check.

The last list is the free physical memory. This cannot be seen as a definitive measure to know the reason for a poor performance but it can be a sign.

Create the Script

So, first we are going to create a folder that is going to have the script that displays the information. I have used c:\utils.

You are going to create a new file in that folder, CheckMemoryCpu.bat in c:\utils.

To do this, open notepad, press WinKey + R, type notepad, and press Enter.

Copy the following text to that file.

@echo off
Powershell -command "&{Get-WmiObject -Query 'Select * from Win32_PerfFormattedData_PerfProc_Process '| Select Name, @{Name='CPU(p)';Expression={$_.PercentProcessorTime}} | where {$_.'CPU(p)' -gt 0 } |Sort 'CPU(p)' -descending | Format-Table -AutoSize;}"
Powershell -command "&{Get-Process | Select Name, @{Name='CPU(s)';Expression={$_.CPU}} | sort 'CPU(s)' -Descending | Select -First 5| Format-Table -AutoSize;}"
Powershell -noexit -command "&{Get-WmiObject -Query 'Select * from Win32_OperatingSystem' | Select FreePhysicalMemory | Format-Table -AutoSize;}"

It’s not the intention of the article to explain every part of this script.

Save it as c:\utils\CheckMemoryCPU.bat:

If you don’t use the hyphens it will create a text file, with the txt extension.

Relax, take a breath. You have done the more complicated part. Now we are going to pin the utility to the Windows 7 Taskbar.

Pin the Script to the Taskbar

We cannot pin the recent created file to the Taskbar directly, therefore we have to use a trick.

To do this we create a new shortcut.

Right click on a folder or over the Desktop and select New > Shortcut.

Type cmd /c  c:\utils\CheckMemoryCPU.bat and click Next.

Windows asks for a name, I have used CheckMemoryCPU but you can use other if you prefer. Click Finish.

To change the icon right click over the shortcut and click Properties.

Click Change Icon.

Windows has several files full of very detailed icons. One I like is located in c:\windows\system32\imageres.dll.

Once you find the file you can use the icon you prefer.

Now that you have your shortcut created you only have to move to the Taskbar.

And this is it. Just click it for a quick glance and what is slowing down your PC.



About Angel Luis

I am an Engineer of Telecommunications that love computers. My first computer was a Commodore 16kb, about 25 years ago and since then I am always fighting computers problems. Please visit my entries and ask me about whatever problem you have, I will be pleased to help you. My email is discoveryourpc [at] gmail [dot] com. You can follow me on twitter @agenlu or read my blog www.discoveryourpc.net

Free PC tips by email

Search Windows Guides




Comments

  • Viki Jacob

    I have a problem with this “CheckMemoryCPU ” file.
    The command window is closing right after I click on the bat file.
    Can anyone help?
    thanks

  • Have you copy the script exactly?

    Have you seen any data before the command window closes?

    Are you using Windows 7?

    Please Viki tell me what you did I want to help you?

    • Viki Jacob

      Thanks Angel for your quick answer.
      1.Yes I made copy – paste of the script.
      2.No,the window is vanishing too fast.I see something writen in red.
      3.yes, I have widows 7.
      Thanks again

  • Change the shortcut to the .bat file to a /k switch (C:WindowsSystem32cmd.exe /k C:UsersYourDesktop123.bat)
    This will keep the command window open after it has executed where you can see what the problem is. i suspect the output will be the same as me.
    http://gyazo.com/6d8522c9a7953521c8ff457032519a

  • Also make sure Word Wrap is not checked when making the batch file.

  • The problem is with copy and paste a to a notepad I will try to fix it.

  • Now it should work.

    It's a problem with HTML.

  • I have updated the article.

    Now it should work.

    It was a problem with copy/paste from a site, maybe a topic for a new article.

    RSRV85 please test it.

    Thanks to all.

  • There was a problem with the way the post was written, now solved.

    Try to copy paste it again.

  • Can conform all is now working. Thanks for updating the script! :)

    http://gyazo.com/c251117dc395d12d11d81d30d093f2

  • What i tend to do with selections of text this this is upload a .txt document and create a link to it. Like in Step 2. here.

  • Also if you use the < code > < /code > tags, it wont replace the characters with curly quotes etc.

  • Viki Jacob

    Thanks Angel,
    now is working all O.K

  • William Preston Cochran

    How can i loop It every 15 seconds?

  • William Preston Cochran

    Never mind I didn’t see the no exit part . Removed that now I have a running Resource Monitor I always Dreamed of thanks man.


Computer tips in your inbox
Sign up for the Windows Guides newsletter to get PC tips and access to free Windows books (More details)

Enter your email address:
 

Popular Guides

See which sites have been visited on your PC (even if private browsing mode is used)

Create a Windows 7 System Repair Disc

Best Free Anti-malware

Hibernate vs. Sleep vs. Shut-Down

i3, i5, and i7; Dual, Quad, Hexa Core Processors. How to they Differ?

Intel's Ivy Bridge Processor: new Features

Submit Your Tip
Submit your computer tip to us; receive full credit for all published tips

Windows Guides on Facebook