【问题标题】:List MS Windows tasks列出 MS Windows 任务
【发布时间】:2013-01-14 15:05:51
【问题描述】:

是否有“内置”方式列出当前正在运行的所有 MS Windows 任务?

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

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"

【问题讨论】:

    标签: r windows-7 task


    【解决方案1】:

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

    > 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)
    

    【讨论】:

    • 是的!非常酷的“命令行功夫”,我什至不知道它存在 ;-) 非常感谢,伙计!
    猜你喜欢
    • 1970-01-01
    • 2019-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-12
    • 2012-11-11
    • 2012-08-30
    • 2011-07-28
    相关资源
    最近更新 更多