1

Is there a "built-in" way to list all MS Windows tasks currently running?

I've googled a bit and found a workaround via shell("tasklist"), but I don't really like the structure of the resulting R object as its pretty "captured-output-only" like (i.e. the resulting object is a character vector containing things like line numbers etc.) and I would have to fire some regular expressions at it to turn it into something like a data frame or the like:

value <- shell("tasklist", intern=TRUE)

> value
 [1] ""                                                                               
 [2] "Abbildname                     PID Sitzungsname       Sitz.-Nr. Speichernutzung"
 [3] "========================= ======== ================ =========== ==============="
 [4] "System Idle Process              0 Services                   0            24 K"
 [5] "System                           4 Services                   0         9.404 K"

 [...]

[96] "tasklist.exe                  6876 Console                    1         6.040 K"
pnuts
  • 58,317
  • 11
  • 87
  • 139
Rappster
  • 12,762
  • 7
  • 71
  • 120

1 Answers1

8

This will return the information in a data frame:

> value <- read.csv(text = shell("tasklist /fo csv", intern = TRUE))
> head(value)
           Image.Name PID Session.Name Session. Mem.Usage
1 System Idle Process   0     Services        0      20 K
2              System   4     Services        0   1,652 K
3            smss.exe 328     Services        0     292 K
4           csrss.exe 468     Services        0   2,140 K
5         wininit.exe 548     Services        0     244 K
6           csrss.exe 564      Console        1  22,416 K

Also try:

View(value)
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341