public class WindowsUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Boolean |
regVersion1 |
Constructor and Description |
---|
WindowsUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
deleteRegistryValue(String key) |
static Class<?> |
discoverRegistryKeyType(String key) |
static boolean |
doesRegistryValueExist(String key) |
static String |
findReg()
Finds reg.exe
|
static File |
findSystemRoot()
Finds the system root directory, e.g.
|
static String |
findTaskKill()
Finds taskkill.exe
|
static File |
findWBEM()
Finds the WBEM directory in the systemRoot directory
|
static String |
findWMIC()
Finds WMIC.exe
|
static String |
getEnvVarIgnoreCase(String var) |
static String |
getLocalAppDataPath()
Returns the path to Local AppData.
|
static com.google.common.collect.ImmutableList<String> |
getPathsInProgramFiles(String childPath) |
static String |
getProgramFiles86Path() |
static String |
getProgramFilesPath()
Returns the path to the Windows Program Files.
|
static boolean |
isRegExeVersion1() |
static void |
kill(String[] cmdarray)
Searches the process list for a process with the specified command line and kills it
|
static void |
killByName(String name)
Kill processes by name
|
static void |
killPID(String processID)
Kills the specified process ID
|
static Properties |
loadEnvironment()
Returns the current process environment variables
|
static void |
main(String[] args) |
static Map<String,String> |
procMap()
Returns a map of process IDs to command lines
|
static boolean |
readBooleanRegistryValue(String key) |
static int |
readIntRegistryValue(String key) |
static String |
readStringRegistryValue(String key) |
static boolean |
thisIsWindows()
Returns true if the current OS is MS Windows; false otherwise
|
static void |
traceWith(Logger log) |
static void |
tryToKillByName(String name)
Kill processes by name, log and ignore errors
|
static void |
writeBooleanRegistryValue(String key,
boolean data) |
static void |
writeIntRegistryValue(String key,
int data) |
static void |
writeStringRegistryValue(String key,
String data) |
public static Boolean regVersion1
public static void traceWith(Logger log)
public static void killByName(String name)
public static void tryToKillByName(String name)
public static void kill(String[] cmdarray) throws Exception
cmdarray
- the array of command line argumentsException
- if something goes wrong while reading the process list or searching for your
command linepublic static void killPID(String processID)
public static Map<String,String> procMap() throws Exception
Exception
- - if something goes wrong while reading the process listpublic static Properties loadEnvironment()
public static String getProgramFilesPath()
public static String getProgramFiles86Path()
public static com.google.common.collect.ImmutableList<String> getPathsInProgramFiles(String childPath)
public static String getLocalAppDataPath()
public static File findSystemRoot()
public static String findWMIC()
public static File findWBEM()
null
if it couldn't be foundpublic static String findTaskKill()
public static String findReg()
public static boolean isRegExeVersion1()
public static int readIntRegistryValue(String key)
public static boolean readBooleanRegistryValue(String key)
public static boolean doesRegistryValueExist(String key)
public static void writeStringRegistryValue(String key, String data) throws WindowsRegistryException
WindowsRegistryException
public static void writeIntRegistryValue(String key, int data)
public static void writeBooleanRegistryValue(String key, boolean data)
public static void deleteRegistryValue(String key)
public static boolean thisIsWindows()
Copyright © 2015. All rights reserved.