Question

Is it possible to write a script that will execute every day in certain time and check size of memory that one process is taking and write that result to an Excel file? That Excel file should be updated every day and old record shouldn't be deleted. OS is Windows Server 2003.

I really don't know anything about scripts and I would be grateful to all of you who help me write this. Thanks.

Was it helpful?

Solution

If you are ok with using CSV format (Excel will open it) instead of XLS, you can easily use the tasklist command for this.

Make a .bat file containing this code:

tasklist /fi "IMAGENAME eq cmd.exe" /fo csv /nh >> c:\report.csv    

Change cmd.exe to the process that you want to track, and c:\report.csv to the filename you want to use for your report.

You can use Windows scheduled tasks to set it to run every day.

Edit: Regarding your comment, I'm assuming you mean current date and time? I'm not sure why you would be getting skipped rows - I don't get that on my machine.

Here's a slightly more complicated script that adds the current date and time to the start of each row:

@echo off
setlocal enableextensions
for /F "usebackq delims=" %%i in (`tasklist /fi "IMAGENAME eq cmd.exe" /fo csv /nh`) do (
    echo "%date% %time%",%%i >> c:\report.csv
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top