code: private long getPID() {
          String commandOutput = executeCommand("$pid").getCommandOutput();
  
          //Remove all non numeric characters
          commandOutput = commandOutput.replaceAll("\\D", "");
  
          if (!commandOutput.isEmpty()) {
              return Long.valueOf(commandOutput);
          }
  
          return -1;
      }
docs: Use Powershell command '$PID' in order to recover the process identifier