Class WindowsProcessUtil

java.lang.Object
net.mcreator.io.WindowsProcessUtil

public class WindowsProcessUtil extends Object
  • Constructor Details

    • WindowsProcessUtil

      public WindowsProcessUtil()
  • Method Details

    • getProcessNameIfExists

      @Nullable public static String getProcessNameIfExists(String partialName) throws Exception
      Retrieves the name of a running process on the system that contains the specified partial name in its details. The method searches through the output of the "tasklist" command.
      Parameters:
      partialName - the partial name of the process to search for (case-insensitive)
      Returns:
      the full name of a running process that matches the partial name, or null if no matching process is found
      Throws:
      Exception - if an error occurs while executing the "tasklist" command or reading its output
    • killProcess

      public static void killProcess(String serviceName) throws Exception
      Terminates a process with the given name forcefully using the "taskkill" command. This method is specific to the Windows operating system and may throw exceptions if the process cannot be terminated or if an error occurs during execution.
      Parameters:
      serviceName - the name of the process to terminate, including the file extension
      Throws:
      Exception - if an error occurs while executing the "taskkill" command, waiting for the command to complete, or during the subsequent delay