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

4

13

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.
Gertiegertrud answered 15/6, 2016 at 17:41 Comment(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.Sarette
B
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 "".

Brueghel answered 24/2, 2020 at 9:12 Comment(1)
I don't see extra spaces nor missing quotesInexorable
W
0

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

Wednesday answered 30/8, 2022 at 16:10 Comment(0)
C
0

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

Chambray answered 23/12, 2022 at 5:24 Comment(0)
C
-1

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"
Capelin answered 24/11, 2023 at 21:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.