Windows 7 - Add Path
Asked Answered
A

6

33

I need to add a new path (sumatraPDF) on my PATH variable.
I don't know why it does not work...
I think everything is right but when I try to execute sumatrapdf.exe from CMD it cannot find the program.

This is what I did: enter image description here

The path is correct, I checked it 1000 times.

The idea is use LaTeX with sublimetext and when I save a .text file sumatra has to open and show to me the result. If I want that I have to add the path of SumatraPDF... but it does not work.

Attlee answered 30/4, 2014 at 23:54 Comment(0)
E
22

I think you are editing something in the windows registry but that has no effect on the path.

Try this:

How to Add, Remove or Edit Environment variables in Windows 7

the variable of interest is the PATH

also you can type on the command line:

Set PATH=%PATH%;(your new path);
Emblematize answered 30/4, 2014 at 23:59 Comment(3)
i added the path exactly your link says... after in the regedit i checked and i saw that the path is correctly added... but it doesnt work. if i print the value of my PATH variable i get this:i61.tinypic.com/epislk.pngAttlee
:-) Remove the "SumatraPDF.exe" from the path. You should only have folders in the path. The way DOS works is that when you type a command on the prompt, DOS will look in the current directory, then search in every directory in the path in environment variable called PATH. It didn't find your exe because there is no directory called "C:\... ...\SumatraPDF\SumatraPDF.exe\". If you change that entry to "C:\... ...\SuatraPDF\" all will be fine.Emblematize
This method is great because it does not require administrative privileges; that's often a problem with my work computer.Langtry
L
14

Another method that worked for me on Windows 7 that did not require administrative privileges:

Click on the Start menu, search for "environment," click "Edit environment variables for your account."

In the window that opens, select "PATH" under "User variables for username" and click the "Edit..." button. Add your new path to the end of the existing Path, separated by a semi-colon (%PATH%;C:\Python27;...;C:\NewPath). Click OK on all the windows, open a new CMD window, and test the new variable.

Langtry answered 25/1, 2017 at 18:57 Comment(2)
Awesome. This one I can remember! Also note that searching for "environment" brings up two links: the one you mentioned for an individual account, AND the one for System Environment variables. The latter of course requires admin privileges. What I like about your solution is that it's easy to remember, AND it works for Both Use Cases. Thanks. I'll never have to look this up again.Orlene
I can only add that on localized versions of Windows one needs to search for localized strings. For example, on Russian version of Windows 7 that'll be "среды".Ellipticity
A
4

I founded the problem: Just insert the folder without the executable file.
so Instead of:

C:\Program Files (x86)\SumatraPDF\SumatraPDF.exe

you have to write this:

C:\Program Files (x86)\SumatraPDF\
Attlee answered 1/5, 2014 at 0:20 Comment(2)
I'm confused, does it add everything with .exe to the $PATH variable when you specify a folder?Circumflex
@KolobCanyon Yes when you add a directory to the PATH environment variables it will source that directory when you open a command terminal and allow you to run executable files by their name without having to change to that directory. This can really make life easier on you if you often use the same tools from CMD. en.wikipedia.org/wiki/PATH_(variable)Astrolabe
W
2

In answer to the OP:

The PATH environment variable specifies which folders Windows will search in, in order to find such files as executable programs or DLLs. To make your Windows installation find your program, you specify the folder that the program resides in, NOT the program file itself!

So, if you want Windows to look for executables (or other desired files) in the folder:

C:\PHP

because, for example, you want to install PHP manually, and choose that folder into which to install PHP, then you add the entry:

C:\PHP

to your PATH environment variable, NOT an entry such as "C:\PHP\php.exe".

Once you've added the folder entry to your PATH environment variable, Windows will search that folder, and will execute ANY named executable file you specify, if that file happens to reside in that folder, just the same as with all the other existing PATH entries.

Before editing your PATH variable, though, protect yourself against foul ups in advance. Copy the existing value of the PATH variable to a Notepad file, and save it as a backup. If you make a mistake editing PATH, you can simply revert to the previous version with ease if you take this step.

Once you've done that, append your desired path entries to the text (again, I suggest you do this in Notepad so you can see what you're doing - the Windows 7 text box is a pain to read if you have even slight vision impairment), then paste that text into the Windows text box, and click OK.

Your PATH environment variable is a text string, consisting of a list of folder paths, each entry separated by semicolons. An example has already been given by someone else above, such as:

C:\Program Files; C:\Winnt; C:\Winnt\System32

Your exact version may vary depending upon your system.

So, to add "C:\PHP" to the above, you change it to read as follows:

C:\Program Files; C:\Winnt; C:\Winnt\System32; C:\PHP

Then you copy & paste that text into the windows dialogue box, click OK, and you should now have a new PATH variable, ready to roll. If your changes don't take effect immediately, you can always restart the computer.

Worcester answered 27/10, 2016 at 9:52 Comment(0)
A
0

The path is a list of directories where the command prompt will look for executable files, if it can't find it in the current directory. The OP seems to be trying to add the actual executable, when it just needs to specify the path where the executable is.

Antebellum answered 16/3, 2016 at 19:51 Comment(0)
M
-3

Try this in cmd:

cd address_of_sumatrapdf.exe_file && sumatrapdf.exe

Where you should put the address of your .exe file instead of adress_of_sumatrapdf.exe_file.

Menadione answered 17/8, 2018 at 15:34 Comment(1)
This does not answer the question on how to add a new entry to the PATH environment variable.Ileneileo

© 2022 - 2024 — McMap. All rights reserved.