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.

6 Answers 6

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);
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.png May 1, 2014 at 0:09
  • 3
    :-) 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. May 1, 2014 at 2:53
  • This method is great because it does not require administrative privileges; that's often a problem with my work computer.
    – Evan
    Jan 25, 2017 at 18:39
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.

2
  • 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. Mar 14, 2017 at 0:14
  • 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 "среды". Nov 1, 2017 at 14:00
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\
2
  • I'm confused, does it add everything with .exe to the $PATH variable when you specify a folder? Mar 16, 2016 at 3:52
  • 1
    @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)
    – iyrin
    Jan 12, 2017 at 8:18
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.

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.

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

1
  • 1
    This does not answer the question on how to add a new entry to the PATH environment variable.
    – Adrian W
    Aug 17, 2018 at 16:02

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.