public class WinEnvVars
extends java.lang.Object
Constructor and Description |
---|
WinEnvVars() |
Modifier and Type | Method and Description |
---|---|
static void |
appendToPath(java.lang.String value)
Appends one or more directories to the PATH environment variable.
|
static void |
appendToUserPath(java.lang.String value)
Appends one or more directories to the user-specific PATH environment variable.
|
static java.util.Properties |
getenv()
Returns all environment variables.
|
static java.lang.String |
getenv(java.lang.String key)
Returns a single environment variable.
|
static java.lang.String |
getFromRegistry(java.lang.String key,
boolean userSpecific)
Return an environment variable as set in the Windows registry.
|
static void |
prependToPath(java.lang.String value)
Prepends one or more directories to the PATH environment variable.
|
static void |
prependToUserPath(java.lang.String value)
Prepends one or more directories to the user-specific PATH environment variable.
|
static void |
set(java.lang.String key,
java.lang.String value)
Sets a global environment variable.
|
static void |
setUserSpecific(java.lang.String key,
java.lang.String value)
Sets a user-specific environment variable.
|
public static void set(java.lang.String key, java.lang.String value) throws java.io.IOException
key
- the name of the environment variablevalue
- the value of the environment variablejava.io.IOException
- if the environment variable could not be setpublic static void setUserSpecific(java.lang.String key, java.lang.String value) throws java.io.IOException
key
- the name of the environment variablevalue
- the value of the environment variablejava.io.IOException
- if the environment variable could not be setpublic static java.lang.String getenv(java.lang.String key)
key
- the name of the environment variable. Case does not matter.null
if not definedpublic static java.util.Properties getenv()
public static java.lang.String getFromRegistry(java.lang.String key, boolean userSpecific) throws java.io.IOException
getenv()
. For example, the PATH
environment variable is modified
by the install4j launcher and is not equal to the system setting. In addition, the value returned for
PATH
will have no variable substitutions performed.userSpecific
- If true
the user-specific variant should be retrieved. Otherwise the global setting
will be returned.null
if not definedjava.io.IOException
- if the environment variable could not be retrievedpublic static void appendToPath(java.lang.String value) throws java.io.IOException
value
- the value to be appended to the pathjava.io.IOException
- if the environment variable could not be setpublic static void prependToPath(java.lang.String value) throws java.io.IOException
value
- the value to be appended to the pathjava.io.IOException
- if the environment variable could not be setpublic static void appendToUserPath(java.lang.String value) throws java.io.IOException
value
- the value to be appended to the pathjava.io.IOException
- if the environment variable could not be setappendToPath(String)
public static void prependToUserPath(java.lang.String value) throws java.io.IOException
value
- the value to be appended to the pathjava.io.IOException
- if the environment variable could not be setprependToPath(String)