To set a temporary or 'per session' environment varible from a command line you can use:
set ‹var name›=‹value>
Make sure your spacing is exactly as shown above, if you add a space between the equal sign the command will fail.
Check: Link for a nice tutorial and info on environment variables.
Answer from akseli on Stack ExchangeTo set a temporary or 'per session' environment varible from a command line you can use:
set ‹var name›=‹value>
Make sure your spacing is exactly as shown above, if you add a space between the equal sign the command will fail.
Check: Link for a nice tutorial and info on environment variables.
If you are using PowerShell, then you need to use the $env prefix for creating an environment variable.
Here's an example:
$env:<var name> = '<value>'
command line - Set Environment Variables Windows - Stack Overflow
Environment Variable Setting via Command Line
How do I set Windows environment variables permanently? - Stack Overflow
Standard users How Do you set Enviroment variables
Videos
Here’s how I’ve done it many times via command line. Run setx /? at a cmd prompt for all the options. /M makes it a system wide variable.
Ex.
ORACLE_HOME is the variable name.
The C:\ path is the value of the variable.
SETX ORACLE_HOME C:\Oracle\product\11.2.0\instantclient_11_2 /M
Is there a command line I can use to set PC and Server environment variables? I have several I have to type in often. It would be nice to write a script to enter them for me.
» pip install python-dotenv
Starting with Windows Vista, the panel can be displayed from the command line (cmd.exe) with a
rundll32 sysdm.cpl,EditEnvironmentVariables
It is from here.
I recommend this: Open the "Run" prompt → type "SystemPropertiesAdvanced". You will be on the Advanced tab of the System Properties window. From here it's easy. I feel this is an easier command to remember than the command prompt's and a good shortcut.
Windows 7: Start menu → in the search bar, type "system variables" and Enter. You will have the Advanced tab of the system properties window open.
Windows 8 and later: Simply type the above in the search box in the task bar.
This can also be achieved from a command prompt. The following example sets a variable at the user level:
SETX variable_name value
For machine level, elevation is required:
SETX variable_name value /m
Right click on Computer, Advanced system settings, select Advanced tab and click Environment variables.
Note: once you modify the environment variables, you will have to restart your applications, including CLI.