Task Manager in Excel – How to use Excel to Monitor Servers or PC?
There are in built application in Windows to view what applications are currently running in your machine, like Task Manager (taskmgr.exe), Performance Monitor (perfmon.exe), Task List (Tasklist.exe).
Anyone can use these applications to monitor tasks/processes/applications/services currently executing in a Windows Machine.
If we suspect any performance or security issue then we usually use these Application Monitoring softwares to check whether any Task is using more memory or CPU.
In case of a PC on can use this manual process. But in case of business critical applications running in a Server system, there is need for an automated process that can monitor the application and system performance.
From this article, we can learn some basics about how to build simple Application Monitoring automation software.
Read Task Manager Applications to Excel
As we know that the Task Manager has the list of softwares currently executed by CPU.
To monitor those processes, we first need to read that list with Excel macro and write it into any worksheet.
First we will be creating an object for Windows Management class and then execute a SQL type of query to pull list of running processes.
There are other different type of queries that can be executed against ‘winmgmts’ to fetch system properties like Motherboard serial number, Manufacturer, model, MAC address, Hard Disk serial numbers etc.,Get Task list in Excel - Task Manager in ExcelVisual Basic1234567891011121314151617Option Explicit'This code is downloaded from Officetricks.com'Visit our site for more Free Excel CodeSub Task_List_In_Excel()Dim oMgmt As Object, oProc As Object, oList As ObjectSet oMgmt = GetObject("winmgmts:")Set oProc = oMgmt.ExecQuery("Select * from Win32_Process")i = 1'Loop thru each process and application nameFor Each oList In oProcThisWorkbook.Sheets(1).Cells(i, 1) = oList.Namei = i + 1NextEnd Sub
There are different methods to do this. One method is to use the Windows Management Object and query it for running processes. Other possible method uses Windows API functions. Click this lick to learn about the alternate process.
Also Read: VBA Option Explicit Not Working - Solved
Terminate Process or Kill Application in Task Manager
The FOR loop in the above, reads each task name and writes it into Excel worksheet. Now, while reading it, we can make the code to check for any application name and terminate it as in below code.How to Terminate Task in ExcelVisual Basic1234567For Each oList In oProc'Check for Application Name. Kill Process if there is a MatchIf vba.Ucase(oList.Name) = vba.Ucase("notepad.exe") ThenoList.TerminateEnd IfNext
Similar to the above code, any unwanted application can be terminated.
To Build Actual Application Monitor
All we have presented above is just few code snippets to show how to fetch and terminate processes. But this does not make a complete Automated Task Monitor.
To build it, we also need to get code from the below pages and integrate them.
- Continuously Monitor the tasks on certain time interval. To do this, we need to have a Timer functionality in Excel.
- Schedule and Execute tasks. Refer this page.
By integrating all these code, we can Schedule, Manage, Initiate and Terminate Tasks right from Excel.
Application Monitor – Manage & Terminate – Tasks Manager
- Games VCF Countif Record Macro Timer in Excel Task Manager print screen HTML Table Import Data Thumbnails Text to Speech TTS Candy Crush Block Apps in FaceBook C++ Programing Machine learning AI bulk email Excel VBA vba color index vba color codes Android social media Twitter Google+ Google Adsense Tips bitcoin Calendar in Excel outlook vba mass email Data Mining Excel Macro Facebook WhatsApp python Wordpress