列出 MS Windows 任务 [英] List MS Windows tasks

查看:33
本文介绍了列出 MS Windows 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种内置"方式可以列出当前正在运行的所有 MS Windows 任务?

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

我在谷歌上搜索了一下,并通过 shell("tasklist") 找到了一种解决方法,但我不太喜欢生成的 R 对象的结构,因为它非常捕获输出-only"之类的(即结果对象是一个包含行号等内容的字符向量),我必须在其上触发一些正则表达式才能将其转换为数据框之类的东西:

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"

推荐答案

这将返回数据框中的信息:

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

也试试:

View(value)

这篇关于列出 MS Windows 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆