System variable PATH Windows

Contents
What is used for
Example
Add a directory to PATH
Explore the PATH contents
Errors
Postgesql

What is used for

When you execute a command in a console, the system looks for a match. between the name of the commands and the program that can be executed.

Searching the entire hard drive would take too long, so search It only works on some directories.

A list of these special directories is stored in the PATH system variable.

Example

Suppose that it is necessary to run a program, for example. Firefox directly from the command line.

Without prior preparation entry Firefox The console will give you an error.

C:\Users\a>firefox

'firefox' is not recognized as an internal or external command, operable program or batch file.

To solve this problem, you need to add a directory with a firefox voice file to PATH.

Add a directory to PATH

A quick way to move on to PATH editing is to press the Win key and type in search. env

Env from www.aredel.com

Step by step:

Right Click on This PC → Properties

My computer Image properties from website www.aredel.com

Additional system settings (advanced system settings)

Control Panel - All Control Panel Items - System image from website www.aredel.com

Additional (Advanced) → Environmental Variables

Environment Variables image from website www.aredel.com

If you want to change for the whole system, then in the window "Variable environments" (System Variables) Find the PATH string in the block System variables (System variables) Click and click the button «Change. .» (Edit...)

If you want to change only for your user, do it in the block. «User variables for %USERNAME%» (User variables for %USERNAME%)

Environment Variables image from website www.aredel.com

Create a New Path (New)

Path Environment Variable image from website www.aredel.com

Enter the address of the directory in which the desired program is located. In our case, this is

C:\Program Files (x86)\Mozilla Firefox

Path Environment Variable image from website www.aredel.com

Restart the console or open a new one and write firefox.

C:\Users\a>firefox

The browser should start.

Explore the PATH contents

PowerShell is enough to do.

echo $Env:Path

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;

Or

Get-ChildItem Env:Path

Name Value ---- ----- Path C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPo...

In cmd.exe see the list of variables environment can be performed by command set No parameters.

set

The output contains system and user variables and additional information. PATH content is highlighted in green.

Results of command set without parameters

Errors

-bash: syntax error near unexpected token `('

Most likely, you are trying to add to the unix PATH address from Windows, with spaces, brackets and so on.

For example:

andrey@olegovich-10:/usr/share$ export PATH=/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath_target_1128437:$PATH

-bash: syntax error near unexpected token `('

To solve this problem, you need to shield spaces and brackets. If there are many routes imported and the input is very long, It’s a little easier to write PATH=$PATH:/path if you get the record right at the end.

You also need to remember that all the extra gaps will break the import - to check you can make the entire script in one line. in a text editor.

It is also important to remember that if you work in bash under Windows . The environment variables must be set through Windows.

andrey@olegovich-10:/usr/share$ export PATH=$PATH:/mnt/c/Program\ Files\ \(x86\)/Common\ Files/Oracle/Java/javapath_target_1128437

Postgesql

Let me give you an example of using psql. bash under Windows This may be useful if you want to add temporarily. Psql path to PATH to run Postrgres script.

In my case, psql.exe is in the folder C:\Program Files\PostgreSQL\12\bin

PATH=$PATH:/mnt/c/Program\ Files/PostgreSQL/12/bin

Related Articles:

Article author: Andrei Olegovich

Related articles
Windows
Loudness Equalization
PowerShell
tail analog in PowerShell
Firewall
Drivers
Developer Mode in Windows 10
BASH in Windows 10
Telnet in Windows 10
PATH system varialbe
Windows Installation on gpt disk

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: