11

I am having trouble understanding why I am getting this error:

ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
Type "SETX /?" for usage.

Implementation

C:\Users>setx JAVA_HOME "C:\DOC\JDK64\1.8.0.74"

SUCCESS: Specified value was saved.

C:\Users>setx PATH "%PATH%;%JAVA_HOME%\bin"
ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
Type "SETX /?" for usage.

C:\Users>setx PATH "%PATH%;%JAVA_HOME%bin"
ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
Type "SETX /?" for usage.
user
  • 854
  • 2
  • 12
  • 28
  • 1
    It means it has already has been added. Also with setx you just add the folder you want added. EG `setx path c:\fred` **adds** fred to the existing path if it's not already present. In short ignore the error. To hide it suffix `> nul` to the command. –  Jun 15 '16 at 21:49

3 Answers3

6

It is quite simple but hidden. run setx /? and I suppose the answer is there. The PATH you give as a parameter (string) contains space/spaces. You should enclose the PTH between "".

Moty
  • 69
  • 1
  • 2
0

This error can also be caused by invisible chars (check for hidden TAB)

0

Try to open your bat file in Notepad++, not windows notepad. You may see invisible whitespaces which should not be there.

zolokonst
  • 11
  • 1