Invalid syntax. Default option is not allowed more than '2' time(s)

user picture user · Jun 15, 2016 · Viewed 8.3k times · Source

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.

Answer

Moty picture Moty · Feb 24, 2020

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