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.
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.
I am pretty sure that the list of applications in task manager is retrieved via EnumWindows, and I dont know if there is a WMI analog to that.
But it's an interesting question, I found a KB article that discusses how you can do it, and I bet it wouldnt be hard to write a wrapper around that code so that you could consume it via a script...
posted by stupidcomputernickname at 6:22 PM on February 7, 2007
But it's an interesting question, I found a KB article that discusses how you can do it, and I bet it wouldnt be hard to write a wrapper around that code so that you could consume it via a script...
posted by stupidcomputernickname at 6:22 PM on February 7, 2007
Response by poster: Molybdenum, I am trying to track any work that I do within any application. Timesnapper will do this by taking screenshots every x interval. You can then play the sequence to review what you worked on.
I would rather have a text log of any application or document that I can filter and track.
It is like the Journal within Outlook but works for any application.
posted by frogmoses at 4:38 AM on February 8, 2007
I would rather have a text log of any application or document that I can filter and track.
It is like the Journal within Outlook but works for any application.
posted by frogmoses at 4:38 AM on February 8, 2007
Best answer: Actually, somebody has already done exactly what was need. See http://www.donationcoder.com/Forums/bb/index.php?topic=4645.new
posted by frogmoses at 8:29 AM on February 9, 2007
posted by frogmoses at 8:29 AM on February 9, 2007
This thread is closed to new comments.
I'm not familiar with TimeSnapper; what are you trying to accomplish?
posted by molybdenum at 6:20 PM on February 7, 2007