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

18.4k Views Asked by At

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

There are 4 best solutions below

1
Moty On

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

0
NullPointerWizard On

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

0
zolokonst On

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

0
LongDev On

i try to set enviroment with powershell it works, but in cmd it throws that erro

setx path "%path%;D:\edge_download\geckodriver-v0.33.0-win64/geckodriver.exe"