fix issues with JAVA_OPTS/ES_JAVA_OPTS in service.bat

fix handling of non-empty JAVA_OPTS
remove usage of if/else that can be tripped by parenthesis in the variable
fixes #4127
closes #4086

(cherry picked from commit fb44e9aef76026f2269f1fdc8832a44f8c76ec8f)