🏠 | 💻 PC | IT-Helpdesk |

PATH system environmental variable

Suppose that you need to run some program, for example Firefox , directly from the command line.

Without preliminary preparation, entering Firefox into the console will throw an error.


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

Right Click This PC → Properties

This PC Properties www.andreyolegovich.ru

Advanced system settings

Control Panel - All Control Panel Items - System www.andreyolegovich.ru

Advanced → Environment Variables

There is a faster way to reach this point - you can press Win button and type PATH in the search field.

Environment Variables www.andreyolegovich.ru

If you plan to change variable for the whole system «System Variables» find PATH line in «System variables» select it and click «Edit...»

If you plan to change it only for your user - concentrate on «User variables for %USERNAME%»

cmd firefox error www.andreyolegovich.ru


cmd firefox error www.andreyolegovich.ru

Paste or type in the folder address where the executable file is located. In our example it is C:\Program Files (x86)\Mozilla Firefox

cmd firefox error www.andreyolegovich.ru

Restart the command window or run a new one and type firefox there.


Browser should start now.

You can check the list of variables by running set command


without additional parameters. As an output you will get both system and user variables plus additional information. PATH content is colored with green.

set without parametes result www.andreyolegovich.ru


-bash: syntax error near unexpected token `('

Most likely you are trying to add Windows like address to unix PATH with all spaces, brackets etc.

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 avoid this error you need to screen spaces and brackets . If multiple PATH are imported and the input is long probably it is easier to write PATH=$PATH:/path , and path will be added to the end of the variable.

You should keep in mind that all unnecessary additional spaces will brake the import. To check if your import is ok you can check it in text editor by puting it to single screen.

Also keep in mind that even if you are working in bash for Windows , system variable should be set via Windows. Or they will be lost after cmd restart

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


Example of using psql from bash for Windows - it can help if you want to temporarly add path psqk to PATH variable to run Postrgres script.

In this example psql.exe is in the C:\Program Files\PostgreSQL\12\bin folder

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

Related articles:

🖧 Remote Desktop
- RDP access from Windows via SSH tunnel
🄭 Access to remove CDROM via RDP
- Installing Windows on GPT disk
- Developer Mode in Windows 10
- Adding Scripts to Autostart
- Environmental variable PATH
- Bash in Windows 10
- Batch files
- Grep, sed, awk
📀 Burning Images with Ultraiso
Windows Hotkeys
- List of Installed Drivers in Windows
🔥 Firewall Windows
Share in social media: