Reputation: 305
I am using batch on windows 7 and I want to store the list of all open programs in a variable. I have tried tasklist and wmic but the list includes the backend processes.
What I am searching for is the list of all the applications started by the user.
Any idea ?
Thanks, SLP
Upvotes: 1
Views: 839
Reputation: 3264
You can get a close approximation to that tab, but its bot going to be perfect.
Let me start out with a few other options.
Services themselves always run under session 0, even if they are running as a given user.
In case you want the processes and services run by or as the current user you are logged on with:
Tasklist -/FI "USERNAME -eq %Username%" /V
If you just want to exclude services and see all processes (and not services) running as any user logged into the system use this:
Tasklist -/FI "SESSION -gt 0" /V
If you want to see only processes that are not services, and only for the current use you can use:
Tasklist -/FI "USERNAME -eq %Username%" /FI "SESSION -gt 0" /V
For a close approximation of the applications tab however we only want windows running as the current user wirh window tirles.
Tasklist -/FI "USERNAME -eq %Username%" /FI "SESSION -gt 0" /V | FIND /I /V " N/A"
Unfortunately windows without titles can also be running but they should have a blank instead of an N/A, of course it's possible to have a window running wirh N/A as its title too; and some processes not listed in the applications tab can have window titles; further there can be items showing in the Application tab that are modules of a process, such as modal windows like the reminder window on outlook, and other items such as searches in explorer which would just show up n/a.
So this isn't perfect, but often its a close enough approximation.
Upvotes: 2