Reputation: 914
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.
Upvotes: 16
Views: 21379
Reputation: 79
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 PATH between "".
Upvotes: 7
Reputation: 426
In the case that I saw, I was actually looking to close at the line causing the problem. I was looking for invisible tab characters, however the line actually read:
setx JAVA_HOME = "something" /m
The problem was that there should not be an equal sign. I removed it and that resolve the issue for me.
Upvotes: 0
Reputation: 221
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"
Upvotes: -1
Reputation: 11
Try to open your bat file in Notepad++, not windows notepad. You may see invisible whitespaces which should not be there.
Upvotes: 0
Reputation: 489
This error can also be caused by invisible chars (check for hidden TAB)
Upvotes: 0