3

My PATH on Windows looks like this:

C:>echo %PATH%
C:\WINDOWS\system32;C:\WINDOWS;C:\dwimperl\perl\bin;C:\dwimperl\perl\site\bin;C:\dwimperl\c\bin;%Path%

What does %Path% mean at the end of the PATH?

Does it have to be at the end? I want to concatenate other directories in the R script and I would naturally put them at the end of the PATH (behind %Path%).

SeanC
  • 3,649
  • 2
  • 20
  • 26
Tomas
  • 7,249
  • 11
  • 44
  • 74
  • 1
    It (`%Path%`) shouldn't be there - you can remove it. And what is `...` doing in the middle? – DavidPostill Dec 12 '14 at 13:04
  • @DavidPostill thanks. `...` was put by me, I just didn't want to post my whole PATH. – Tomas Dec 12 '14 at 14:23
  • -1 somebody gave an answer referencing something in your question and you since edited it out, that made part of his answer unclear and led me to comment on it asking for elaboration. Next time if you are to edit your question in a way that affects or might affect some previous answers then use a strike through asdf – barlop Dec 12 '14 at 15:09
  • @barlop, I edited it out because it was confusing people here! I wanted to respond to Anthony but I was interrupted and had to do something urgent in the office. Please remove the downvote. – Tomas Dec 12 '14 at 15:20
  • @barlop I think a downvote is a little harsh. My comment on the PATH components was more of an aside than an important part of my answer. Strikethroughs can add visual clutter and make it that little bit harder for future readers to grasp the essential point of the question. – Anthony Geoghegan Dec 12 '14 at 16:58
  • Now that the question and answer read ok together, as the answerer has done one of the suggestions, I will remove the downvote. – barlop Dec 12 '14 at 19:57

1 Answers1

4

That looks like a mistake in some other script / batch command where a literal %PATH% was appended to the PATH instead of the contents of the PATH environment variable. This would have happened if the PATH wasn’t already set when the script set the PATH environment variable. If an environment variable isn’t actually set, %PATH% expands to a literal %PATH%.

Unset the PATH environment variable:

C:\>set PATH=

See what %PATH% expands to:

C:\>echo %PATH%
%PATH%

Attempt to prepend a directory to the current PATH (which isn't actually set):

C:\>set PATH=C:\Perl;%PATH%

C:\>echo %PATH%

C:\Perl;%PATH%
Anthony Geoghegan
  • 3,761
  • 22
  • 41
  • You write "By the way, there are other entries listed in your path that don’t look valid for MS Windows." <-- can you expand on that? – barlop Dec 12 '14 at 14:34
  • @barlop Tomas has since edited his question to remove `...` as one of the directories in his PATH. `C:\dwimperl \c\bin;` (with space in directory name) also didn't look right given that `C:\dwimperl\perl\bin` and `C:\dwimperl\perl\site\bin` (without space) have already been listed. – Anthony Geoghegan Dec 12 '14 at 14:51
  • better to have quoted what you meant, because even if he hadn't edited his question, it's still a hassle to have to scroll up and look at his question to see what you might've been referring to. And it has the further advantage that it doesn't become clear if he edits it out of his question. (though he should've used strikethrough). – barlop Dec 12 '14 at 15:11
  • Thanks Anthony! This looks like an explanation! I removed the confusing `...` part from my answer. – Tomas Dec 12 '14 at 15:22
  • @barlop Fair point. For future readers, I've edited my answer to remove reference to the erroeneous PATH components. In any case, it was more of an aside which is why I used the phrase "By the way". – Anthony Geoghegan Dec 12 '14 at 16:46
  • Anthony, so my general conclusion is, that I can simply ignore the %Path% and add things behind it, right? (I am not really into debugging system scripts to fix it unless it actually causes any problem.) – Tomas Dec 15 '14 at 09:33
  • 1
    It won't do any harm. It just means that running a command from the command line will take an extra few micro-seconds for the command interpreter to determine that the `%Path%` directory (probably ) doesn't exist. -- I say "probably" because the percentage sign *is* a valid character for a Windows file / directory name. – Anthony Geoghegan Dec 15 '14 at 10:07
  • If you ever feel that your PATH is geting too cluttered, I'd recommend reading the answers to [this question](http://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them). – Anthony Geoghegan Dec 15 '14 at 10:08