You can use setx env var [/M] as mentioned above.If it doesn't take effect you can use refreshenv to refresh environment variables. You don't have to restart your computer, explorer.exe or your command prompt to do that.
I want to add that if you are using the /s parameter with setx in order to set environment variables on a remote computer, the "Remote Registry" service needs to be running on the target machine or else you will receive a "ERROR: The specified operation could not be completed."
WARNING: This solution may be destructive to your PATH, and the stability of your system. As a side effect, it will merge your user and system PATH, and truncate PATH to 1024 characters. The effect of this command is irreversible. Make a backup of PATH first. See the comments for more information.
Like Danial Wilson noted in comment below, it sets the path only in the current session. To set the path permanently, use setx but be aware, although that sets the path permanently, but not in the current session, so you have to start a new command line to see the changes. More information is here.
Here's a full example that works on Windows 7 to set the PATH environment variable system wide. The example detects if the software has already been added to the PATH before attempting to change the value. There are a number of minor technical differences from the examples given above:
Checking the above suggestions on Windows 10 LTSB, and with a glimpse on the "help" outlines (that can be viewed when typing 'command /?' on the cmd), brought me to the conclusion that the PATH command changes the system environment variable Path values only for the current session, but after reboot all the values reset to their default- just as they were prior to using the PATH command.
On the other hand using the SETX command with administrative privileges is way more powerful. It changes those values for good (or at least until the next time this command is used or until next time those values are manually GUI manipulated... ).
where any equal sign '=' should be avoided, and don't you worry about spaces! There isn't any need to insert any more quotation marks for a path that contains spaces inside it - the split sign ';' does the job.
The PATH keyword that follows the SETX defines which set of values should be changed among the System Environment Variables possible values, and the %PATH% (the word PATH surrounded by the percent sign) inside the quotation marks, tells the OS to leave the existing PATH values as they are and add the following path (the one that follows the split sign ';') to the existing values.
In paths, use \\ to separate folder names in key paths as regedit uses a single \ to separate its key names. All reg files start with REGEDIT4. A semicolon turns a line into a comment. The @ symbol means to assign the value to the key rather than a named value.
I am running Windows 7 x64. I did a manual update to the system PATH variable. This worked okay if I ran cmd.exe from the stat menu. But if I type "cmd" in the Windows Explorer address bar, it seems to load the PATH from elsewhere, which doesn't have my manual changes.
In my case it was just that I copied the path from the properties dialog box in Windows and it contained a blank character or something else in the text so it was not recognized. I pasted the path text in a plain text file and removed everything to the sides and my variable was recognized.
As an additional bit of information: While SET works with global or system variables, sometimes you want to write and read User variables, and this is done with the SETX command. SETX is included in the base installs of Windows beginning with Vista, but was also available in Windows XP by installing the Resource Pack.
One difference about SETX though is that you cannot read the variable out in the same command window you wrote it in. You have to write the SETX command in one Command or Powershell window, and then open a new window to read it using ECHO.
The solution was a bit different for me: it won't recognize the system environment variable JAVA_HOME, so I had to set JAVA_HOME as User environment variable, so that i can use %JAVA_HOME% in system environment variable setting up.
The characters , , &, and ^ are special command shell characters, and they must be preceded by the escape character (^) or enclosed in quotation marks when used in (for example, "StringContaining&Symbol"). If you use quotation marks to enclose a string that contains one of the special characters, the quotation marks are set as part of the environment variable value.
Use environment variables to control the behavior of some batch files and programs and to control the way Windows and the MS-DOS subsystem appears and works. The set command is often used in the Autoexec.nt file to set environment variables.
If you use the set command without any parameters, the current environment settings are displayed. These settings usually include the COMSPEC and PATH environment variables, which are used to help find programs on disk. Two other environment variables used by Windows are PROMPT and DIRCMD.
If you specify values for and , the specified value is added to the environment and is associated with that variable. If the variable already exists in the environment, the new string value replaces the old string value.
If you use logical (&& or ) or modulus (%) operators, enclose the expression string in quotation marks. Any non-numeric strings in the expression are considered environment variable names, and their values are converted to numbers before they're processed. If you specify an environment variable name that isn't defined in the current environment, a value of zero is allotted, which allows you to perform arithmetic with environment variable values without using the % to retrieve a value.
If you call a variable value from a batch file, enclose the value with percent signs (%). For example, if your batch program creates an environment variable named BAUD, you can use the string associated with BAUD as a replaceable parameter by typing %baud% at the command prompt.
The set command assigns everything that follows the equal sign (=) to the value of the variable. Therefore, if you type set testVar=TEST^1, you'll get the following result, testVar=TEST1.
You can then use the string c:\directory in batch files by enclosing the name include with percent signs (%). For example, you can use dir %include% in a batch file to display the contents of the directory associated with the include environment variable. After this command is processed, the string c:\directory replaces %include%.
Setting the environment variable changes the value used until the end of your shell session, or until you set the variable to a different value. You can make the variables persistent across future sessions by setting them in your shell's startup script.
Using setx to set an environment variable changes the value used in both the current command prompt session and all command prompt sessions that you create after running the command. It does not affect other command shells that are already running at the time you run the command. You may need to restart you terminal for settings to load.
If you set an environment variable at the PowerShell prompt as shown in the previous examples, it saves the value for only the duration of the current session. To make the environment variable setting persistent across all PowerShell and Command Prompt sessions, store it by using the System application in Control Panel. Alternatively, you can set the variable for all future PowerShell sessions by adding it to your PowerShell profile. See the PowerShell documentation for more information about storing environment variables or persisting them across sessions.
If the source and destination buckets are the same when using custom the s3 mv command, the source file or object can be moved onto itself, which can result in accidental deletion of your source file or object. The AWS_CLI_S3_MV_VALIDATE_SAME_S3_PATHS environment variable and --validate-same-s3-paths option specifies whether to validate your access point ARNs or access point aliases in your Amazon S3 source or destination URIs.
The Default region name identifies the AWS Region whose servers you want to send your requests to by default. This is typically the Region closest to you, but it can be any Region. For example, you can type us-west-2 to use US West (Oregon). This is the Region that all later requests are sent to, unless you specify otherwise in an individual command.
You must specify an AWS Region when using the AWS CLI, either explicitly or by setting a default Region. For a list of the available Regions, see Regions and Endpoints. The Region designators used by the AWS CLI are the same names that you see in AWS Management Console URLs and service endpoints.
Endpoint configuration settings are located in multiple places, such as the system or user environment variables, local AWS configuration files, or explicitly declared on the command line as a parameter. The AWS CLI endpoint configuration settings take precedence in the following order:
Any default endpoint URL for the respective AWS service is used last. For a list of the standard service endpoints available in each Region, see AWS Regions and Endpoints in the Amazon Web Services General Reference.
Specifies a custom endpoint that is used for a specific service, where is replaced with the AWS service identifier. For example, Amazon DynamoDB has a serviceId of DynamoDB. For this service, the endpoint URL environment variable is AWS_ENDPOINT_URL_DYNAMODB.
c80f0f1006