在R系统功能中使用斜杠选项

时间:2018-11-28 20:04:15

标签: r cmd system

我正在尝试在R中使用以下cmd函数

rmdir /q /s myDir

我尝试过:

 system("rmdir /q /s myDir")

但返回错误:

rmdir: failed to remove '/q': No such file or directory
rmdir: failed to remove '/s': No such file or directory
rmdir: failed to remove 'public_html/croecon.contentio.biz': Directory not empty

我应如何使用斜杠选项,例如/ q?

1 个答案:

答案 0 :(得分:1)

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2") 
Set objEvents = objWMIService.ExecNotificationQuery("SELECT * FROM Win32_ProcessStartTrace")
Do
    Set objReceivedEvent = objEvents.NextEvent
    Set colItems = objWMIService.ExecQuery("Select * From Win32_Process where ProcessID=" & objReceivedEvent.ProcessID)
    For Each objItem in colItems
        wscript.echo objItem.name & " " & objItem.ProcessID & " " & objItem.CommandLine    
    Next
Loop

然后在命令提示符下键入

cscript //nologo C:\folder\MonitorProcessCreation.vbs

这将监视运行命令时的开始情况。