Package net.mcreator.io
Class WindowsProcessUtil
java.lang.Object
net.mcreator.io.WindowsProcessUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetProcessNameIfExists(String partialName) Retrieves the name of a running process on the system that contains the specified partial name in its details.static voidkillProcess(String serviceName) Terminates a process with the given name forcefully using the "taskkill" command.
-
Constructor Details
-
WindowsProcessUtil
public WindowsProcessUtil()
-
-
Method Details
-
getProcessNameIfExists
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
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
-