util_find_pid: R function to find PID of active applications

Description Usage Arguments Details Value Author(s) Examples

View source: R/util_find_pid.R

Description

Utility function to find PID of the working terminal.exe application Function is created to generate a system call to programmatically close any given application

[Experimental]

Usage

1
util_find_pid(tasks_running = t_running, pid_pattern = "terminal.exe")

Arguments

tasks_running
  • string, vector with system tasks

pid_pattern
  • string, pattern value to search application with

Details

Function is executing a system command to get all processes running on the OS Retrieved data is cleaned and organized to filter on required process Function can also be used to track specific applications defined by the user

Value

string with system kill command to close selected application

Author(s)

(C) 2021 Vladimir Zhbanko

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(magrittr)
library(tibble)
library(stringr)
library(dplyr)

#library(readr)


dir <- normalizePath(tempdir(),winslash = "/")


#tasks_running <- system("tasklist", intern = TRUE)
#writeLines(tasks_running, con = file.path(dir,'tasks_running.txt'))
#t_running <- readLines(con = file.path(dir,'tasks_running.txt'))

tasks_list = system.file("extdata", "tasks_running.txt",
                  package = "lazytrade")

t_running <- readLines(con = tasks_list)

#generate task kill command for this application
util_find_pid(tasks_running = t_running,
              pid_pattern = 'terminal.exe')

util_find_pid(tasks_running = t_running,
              pid_pattern = 'chrome.exe')

lazytrade documentation built on Dec. 16, 2021, 1:06 a.m.