org.openqa.selenium.os
Class WindowsUtils

java.lang.Object
  extended by org.openqa.selenium.os.WindowsUtils

public class WindowsUtils
extends Object


Field Summary
static Boolean regVersion1
           
 
Constructor Summary
WindowsUtils()
           
 
Method Summary
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 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regVersion1

public static Boolean regVersion1
Constructor Detail

WindowsUtils

public WindowsUtils()
Method Detail

main

public static void main(String[] args)
                 throws Exception
Parameters:
args -
Throws:
Exception

traceWith

public static void traceWith(Logger log)

killByName

public static void killByName(String name)
Kill processes by name


tryToKillByName

public static void tryToKillByName(String name)
Kill processes by name, log and ignore errors


kill

public static void kill(String[] cmdarray)
                 throws Exception
Searches the process list for a process with the specified command line and kills it

Parameters:
cmdarray - the array of command line arguments
Throws:
Exception - if something goes wrong while reading the process list or searching for your command line

procMap

public static Map<String,String> procMap()
                                  throws Exception
Returns a map of process IDs to command lines

Returns:
a map of process IDs to command lines
Throws:
Exception - - if something goes wrong while reading the process list

loadEnvironment

public static Properties loadEnvironment()
Returns the current process environment variables

Returns:
the current process environment variables

getProgramFilesPath

public static String getProgramFilesPath()
Returns the path to the Windows Program Files. On non-English versions, this is not necessarily "C:\Program Files".

Returns:
the path to the Windows Program Files

getProgramFiles86Path

public static String getProgramFiles86Path()

getPathsInProgramFiles

public static com.google.common.collect.ImmutableList<String> getPathsInProgramFiles(String childPath)

getLocalAppDataPath

public static String getLocalAppDataPath()
Returns the path to Local AppData. For different users, this will be different.

Returns:
the path to Local AppData

getEnvVarIgnoreCase

public static String getEnvVarIgnoreCase(String var)

findSystemRoot

public static File findSystemRoot()
Finds the system root directory, e.g. "c:\windows" or "c:\winnt"


findWMIC

public static String findWMIC()
Finds WMIC.exe

Returns:
the exact path to wmic.exe, or just the string "wmic" if it couldn't be found (in which case you can pass that to exec to try to run it from the path)

findWBEM

public static File findWBEM()
Finds the WBEM directory in the systemRoot directory

Returns:
the WBEM directory, or null if it couldn't be found

findTaskKill

public static String findTaskKill()
Finds taskkill.exe

Returns:
the exact path to taskkill.exe, or just the string "taskkill" if it couldn't be found (in which case you can pass that to exec to try to run it from the path)

findReg

public static String findReg()
Finds reg.exe

Returns:
the exact path to reg.exe, or just the string "reg" if it couldn't be found (in which case you can pass that to exec to try to run it from the path)

isRegExeVersion1

public static boolean isRegExeVersion1()

discoverRegistryKeyType

public static Class<?> discoverRegistryKeyType(String key)

readStringRegistryValue

public static String readStringRegistryValue(String key)

readIntRegistryValue

public static int readIntRegistryValue(String key)

readBooleanRegistryValue

public static boolean readBooleanRegistryValue(String key)

doesRegistryValueExist

public static boolean doesRegistryValueExist(String key)

writeStringRegistryValue

public static void writeStringRegistryValue(String key,
                                            String data)
                                     throws WindowsRegistryException
Throws:
WindowsRegistryException

writeIntRegistryValue

public static void writeIntRegistryValue(String key,
                                         int data)

writeBooleanRegistryValue

public static void writeBooleanRegistryValue(String key,
                                             boolean data)

deleteRegistryValue

public static void deleteRegistryValue(String key)

thisIsWindows

public static boolean thisIsWindows()
Returns true if the current OS is MS Windows; false otherwise

Returns:
true if the current OS is MS Windows; false otherwise


Copyright © 2013. All rights reserved.