All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zeroturnaround.process.win.WmicUtil Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version
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