Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const cutCMD = function(cmd, processName) {
- let c = cmd;
- if (!c || c.length === 0) {
- return null;
- }
- c = c.trim();
- if (processName.indexOf(".exe")) {
- processName = processName.replace(/\.exe$/i, ""); // Remove .exe from processName
- }
- // skip regex symbols
- processName = skipRegex(processName);
- // Find what is have to be removed from cmd in a process tree
- let strToRemove = c.match(new RegExp(`^(.*?)${processName}([^\\s]+)?`, "i"));
- // If has sth to remove
- if (strToRemove) {
- // Remove string from cmd
- c = c.replace(strToRemove[0].trim(), "");
- }
- // Trim and return resulting cmd
- return c && c.trim();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement