Logging applications using WMI
February 7, 2007 2:09 PM
Subscribe
Looking for help in creating an automatic journal application for tracking my tasks using WMI.
I like the functionality of TimeSnapper but instead of capturing screenshots I want my output to go to a text file. I'm sure Microsoft's WMI scripting can accomplish this but I need some guidance on coding it.
How it might work:
Monitor the Process list every X interval. For each Process, write the document/application name and current time into a text file. The code might be something like this (pseudo code in []):
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process" WHERE [process(es) = filter list])
For Each Item in colProcesses
objTextFile.WriteLine Item.[actual filename of any document running under this process] & [time]
Next
The issue is that one Process can have more than one 'Application' running at one time. This means you can't use the Process information by itself. If you look at Task Manager when multiple Word documents are open, you will see each document in the Applications tab but only one Winword.exe in the Process tab.
I want the individual Application(s) listed in the log so as to have a complete record of any work I did in any application that day.
I just need some guidance how to get the "application" listing through WMI.
posted by frogmoses to computers & internet (4 comments total)
I'm not familiar with TimeSnapper; what are you trying to accomplish?
posted by molybdenum at 6:20 PM on February 7, 2007