How to set path variable in windows

How to set the path and environment variables in Windows

Setting the path and environment variables will differ depending on the version of Windows you have on your computer. Choose a link below for your version of Windows.

Administrator privileges are usually required to modify the path and environment variables.

Setting the path and variables in Windows 10

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the variable name and variable value.

To view and set the path in the Windows command line, use the path command.

Setting the path and variables in Windows 8

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the variable name and variable value.

To view and set the path in the Windows command line, use the path command.

Setting the path and variables in Windows Vista and Windows 7

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the Variable name and Variable value.

To view and set the path in the Windows command line, use the path command.

Setting the path and variables in Windows 2000 and Windows XP

The path is now managed by Windows 2000 and Windows XP and not the autoexec.bat or autoexec.nt files, as was done with earlier versions of Windows. To change the system environment variables, follow the steps below.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

You can edit other environment variables by highlighting the variable in the System variables section and clicking Edit. If you need to create a new environment variable, click New and enter the Variable name and Variable value.

To view and set the path in the Windows command line, use the path command.

What is the default Windows %PATH%?

The path is based on programs installed on the computer, so there is no «default path.» However, the Windows minimum path is often the path below.

Keep in mind that as you install programs, the path is updated with the paths for the newly installed programs. So, if you have erased your path after installing other programs, those programs may be affected.

Setting path in the MS-DOS and Windows command line

To view and set the path in MS-DOS and in the Windows command line, use the path command.

Источник

How to Add to Windows PATH Environment Variable

Works for Windows 10 or 7

If you’re a coder or programmer, you probably spend a decent amount of time using the command prompt to execute programs or compile code. In order to complete those tasks, you most likely have to use a command from a library or software package installed (like Python) on your system.

By default, most of these programs will add their own custom shortcuts to the Windows environment variables. The most used environment variable in Windows is probably the PATH variable. It basically allows you to run any executables that are located inside the paths specified in the variable at the command prompt without having to give the full path to the executable.

In this article, I’ll show you how you can add more paths to the Windows PATH variable in case you want to run executables from your own custom directories. It’s worth noting that the procedure below is for Windows 10, but it’s almost exactly the same for Windows 7 also.

Add Directories to PATH Variable

To get started, right-click on the Computer or This PC icon on the desktop and select Properties. If you don’t have that icon on your desktop already, you can add any missing desktop icons easily.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

On the System dialog page, you’ll see an Advanced system settings link on the left-hand side.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

This will bring up the System Properties dialog, which should already be open to the Advanced tab. Go ahead and click on the Environment Variables button at the very bottom.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

On the Environment Variables dialog, you’ll see two sets of variables: one for user variables and the other for system variables. Both lists have the PATH variable, so you have to decide which one to edit.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

If you only need the commands for your own user account, then edit the user variable. If you need it to work across the computer system regardless of which user is logged in, then edit the system variable. Click on Path and then click on Edit.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

On the Edit environment variable dialog, you’ll see a list of all the paths that are currently in the PATH variable. As you can see, Node.js and Git already added their paths so that I can run Git commands and Node.js commands from anywhere while in the command prompt.

To add a new path, simply click on New and it’ll add a new line to the bottom of the list. If you know the path, simply type it in or copy and paste it. If you prefer, you can also click Browse and then navigate to the desired path.

To edit any path, simply select it and then click on the Edit button. You can also delete paths using the Delete button. Note that you can also move items up and down on the list. When you type a command at the command prompt, Windows has to search through each directory stored in the PATH variable to see if that executable exists or not. If you want your executable to be found faster, just move that path up to the top of the list.

This can also come in handy if you have multiple versions of the same command in different paths and need to have one run instead of the other. The one that shows up higher in the list will be run when you type in the command.

Lastly, if you click on Edit text, it will load a dialog where you can edit the Path variable using the old interface where all the paths are listed in one text box.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

That’s all there is to it! If you want to learn more about environment variables, make sure to check out my post on how to create your own custom environment variables. Enjoy!

Founder of Help Desk Geek and managing editor. He began blogging in 2007 and quit his job in 2010 to blog full-time. He has over 15 years of industry experience in IT and holds several technical certifications. Read Aseem’s Full Bio

Источник

Set path from command line

Users can run an executable from windows command prompt either by giving the absolute path of the file or just by the executable file name. In the latter case, Windows searches for the executable in a list of folders which is configured in environment variables. These environment variables are as below.

1. System path
2. User path

The values of these variables can be checked in system properties( Run sysdm.cpl from Run or computer properties). Initially user specific path environment variable will be empty. Users can add paths of the directories having executables to this variable. Administrators can modify the system path environment variable also.

How to set path from command line?

In Vista, Windows 7 and Windows 8 we can set path from command line using ‘setx’ command.

For example, to add c:\dir1\dir2 to the path variable, we can run the below command.

Alternative way is to use Windows resource kit tools ‘pathman.exe‘. Using this command we can even remove a directory from path variable. See download windows resource kit tools. This works for Windows 7 also.

Add directory to system path environment variable:

Open administrator command prompt
Run the below command

Remove path from system path environment variable:
Run the below command from elevated command prompt

Setting user path environment variable

For user environment varlables, admin privileges are not required. We can run the below command to add a directory to user path environment variable.

To remove a directory from user path, you can run the below command.

Default option is not allowed more than ‘2’ time(s)

You get this error if you have not enclosed ‘path’ in double quotes. See the below example for setting the path of firefox.

Now if you move %path% to be in the double quotes

Could a context entry be created for folders, perhaps an extended one… to add to path?

what about a multi-verb option, like copy as path?

Johny Why
Answer: Try add the parameter /M

Hi, is there a way I can add an extra variable instead on deleting the currently one and put a new Variable on the Path.

Nuno, pathman described above does exactly that. You can download the resource tools kit and get it.

setx path “%path%;C:\yourFolder”

To set path for java & javac, can I add the paths to PATH or do I need to create the environment variable JAVA_HOME. I don’t have this defined, but windows does not seem to be able to find java binaries on my system.

You can directly add the folder to PATH. No need to define JAVA_HOME. However, adding JAVA_HOME separately avoids cluttering and helps to easily understand what is added.

hello, can someone plz explain this result? After setting path, it did not change. This was run from an Administrator command-line:

C:\Windows\system32>setx path “C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;D:\Program Files (x86)\Microsoft VS Code\bin”

SUCCESS: Specified value was saved.

C:\Windows\system32>path
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin;D:\Program Files (x86)\Microsoft VS Code\bin;D:\Program Files (x86)\metapad36;D:\Program Files (x86)\metapad36″ /M

Why won’t this work?

SET EPO = D:\Program Files (x86)\McAfee\ePolicy Orchestrator
PATH = %PATH%;%EPO%\jre\bin;%EPO%\apache2\bin

In windows 10 set path %path%; not working. it’s work like :
setx “%path%;C:\Program Files\CodeBlocks\MinGW\bin”

By unfortunately I deleted my system default path. How could I able to find my system path?

Unfortunately I deleted several files with unremembered path names. This article was useful

The following used to work for me when I am in MSDOS environment. Lately I get error messages such as INCLUDE not found. Why is this so?

Used to work
SET PLL =c:\CL5\PLL
SET PLT =c:\CL5\PLL
SET INCLUDE =c:\CL5\INCLUDE
SET PRG =c:\IMS\PRG
SET LIB =c:\CL5\LIB
SET OBJ =c:\CL5\OBJ
PATH =c:\IMS\EXE;\CL5\BIN;\CL5\NG;\CL5\PLL

pathman is one of many tools of the Windows Server 2003 Resource Kit Tools

Note: The Windows Server 2003 Resource Kit Tools are not supported on 64-bit platforms.

Huh.
When I did that on Windows 10 v1903, using setx, it replaced the USER scope paths with the SYSTEM scope paths.
Now I’m not sure what was in the old user path.
So, uh… Be careful out there.
And if anyone has a solution how to avoid that, please let me know
Thanks

Источник

Adding a directory to the PATH environment variable in Windows

I am trying to add C:\xampp\php to my system PATH environment variable in Windows.

I have already added it using the Environment Variables dialog box.

But when I type into my console:

it doesn’t show the new C:\xampp\php directory:

I have two questions:

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

18 Answers 18

This only modifies the registry. An existing process won’t use these values. A new process will do so if it is started after this change and doesn’t inherit the old environment from its parent.

You didn’t specify how you started the console session. The best way to ensure this is to exit the command shell and run it again. It should then inherit the updated PATH environment variable.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

Option 1

After you change PATH with the GUI, close and re-open the console window.

Option 2

Execute this command in the command window you have open:

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.

Don’t blindly copy-and-paste this. Use with caution.

You can permanently add a path to PATH with the setx command:

You should run this command from an elevated command prompt.

If you only want to change it for the current session, use set.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

You don’t need any set or setx command. Simply open the terminal and type:

This shows the current value of PATH variable. Now you want to add directory to it? Simply type:

If for any reason you want to clear the PATH variable (no paths at all or delete all paths in it), type:

Update

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.

To check if an environmental variable exist or see its value, use the ECHO command:

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

I would use PowerShell instead!

To add a directory to PATH using PowerShell, do the following:

To set the variable for all users, machine-wide, the last line should be like:

In a PowerShell script, you might want to check for the presence of your C:\xampp\php before adding to PATH (in case it has been previously added). You can wrap it in an if conditional.

So putting it all together:

Better still, one could create a generic function. Just supply the directory you wish to add:

You could make things better by doing some polishing. For example, using Test-Path to confirm that your directory actually exists.

Safer SETX

Warnings

The ss64 SETX page has some very good examples. Importantly it points to where the registry keys are for SETX vs SETX /M

Usage instructions

Append to User PATH

Append to System PATH

(It’s basically the same except with a different Key and the SETX /M modifier.)

Alternatives

Finally there’s potentially an improved version called SETENV recommended by the ss64 SETX page that splits out setting the user or system environment variables.

1. Not strictly true

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

Handy if you are already in the directory you want to add to PATH:

It works with the standard Windows cmd, but not in PowerShell.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

To override already included executables;

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

Aside from all the answers, if you want a nice GUI tool to edit your Windows environment variables you can use Rapid Environment Editor.

Try it! It’s safe to use and is awesome!

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

It does things in an intuitive way. For example:

It shows results without the need to spawn a new cmd!

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

Regarding point 2 I’m using a simple batch file that is populating PATH or other environment variables for me. Therefore, there is no pollution of environment variables by default. This batch file is accessible from everywhere so I can type:

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

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. ).

The best SETX syntax usage that worked for me:

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.

Источник

Setting a system environment variable from a Windows batch file?

Is it possible to set a environment variable at the system level from a command prompt in Windows 7 (or even XP for that matter). I am running from an elevated command prompt.

When I use the set command ( set name=value ), the environment variable seems to be only valid for the session of the command prompt.

7 Answers 7

The XP Support Tools (which can be installed from your XP CD) come with a program called setx.exe :

I think Windows 7 actually comes with setx as part of a standard install.

Simple example for how to set JAVA_HOME with setx.exe in command line:

This will set environment variable «JAVA_HOME» for current user. If you want to set a variable for all users, you have to use option «-m». Here is an example:

Note: you have to execute this command as Administrator.

Note: Make sure to run the command setx from an command-line Admin window

1 like so: setx /M JAVA_HOME «C:\Progra

1\Java\jdk1.7.0_09″ – samael Jul 31 ’13 at 10:01

If you set a variable via SETX, you cannot use this variable or its changes immediately. You have to restart the processes that want to use it.

Use the following sequence to directly set it in the setting process too (works for me perfectly in scripts that do some init stuff after setting global variables):

For XP, I used a (free/donateware) tool called «RAPIDEE» (Rapid Environment Editor), but SETX is definitely sufficient for Win 7 (I did not know about this before).

System variables can be set through CMD and registry For ex. reg query «HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment» /v PATH

All the commonly used CMD codes and system variables are given here: Set Windows system environment variables using CMD.

Open CMD and type Set

You will get all the values of system variable.

Type set java to know the path details of java installed on your window OS.

How to set path variable in windows. Смотреть фото How to set path variable in windows. Смотреть картинку How to set path variable in windows. Картинка про How to set path variable in windows. Фото How to set path variable in windows

Just in case you would need to delete a variable, you could use SETENV from Vincent Fatica available at http://barnyard.syr.edu/

vefatica. Not exactly recent (’98) but still working on Windows 7 x64.

SetX is the command that you’ll need in most of the cases.Though its possible to use REG or REGEDIT

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *