
org.zeroturnaround.process.win.WmicUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zt-process-killer Show documentation
Show all versions of zt-process-killer Show documentation
A library for stopping external processes from Java.
package org.zeroturnaround.process.win;
import java.io.File;
import org.apache.commons.lang.SystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Helper for locating WMIC.exe
which is usually at C:\Windows\System32\Wbem
.
*/
public class WmicUtil {
private static final Logger log = LoggerFactory.getLogger(WmicUtil.class);
private static final File PATH = findPath();
public static File getPath() {
return PATH;
}
private static File findPath() {
String name = "WMIC.exe";
File result = new File(name); // As a fallback use a relative path
if (SystemUtils.IS_OS_WINDOWS) {
String windows = System.getenv().get("SYSTEMROOT"); // C:\Windows
if (windows != null) {
result = new File(windows, "System32/Wbem/" + name);
}
}
log.debug("Using {} at {}", name, result);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy