Escape list of JVM arguments in .bat file correctly -


i have bat-file in i'm trying pass jvm list of non proxy hosts via "-dhttp.nonproxyhosts". file contains list of arguments , if try add 1 in question this:

set "java_opts=-xms64m -xmx1024m -xx:maxpermsize=256m" ... set "java_opts=%java_opts% -dhttp.nonproxyhosts=*.company.com|localhost|127.0.0.1" 

windows tells me "command 'localhost' not found".

and if try escape like

set "java_opts=%java_opts% -dhttp.nonproxyhosts=*.company.com^|localhost^|127.0.0.1" 

the result pretty same, how pass list correctly?

cheers simon

i suppose problem isn't set, it's later when use java_opts variable.

the best way use delayed expansion here, it's ignore special characters @ all.

setlocal enabledelayedexpansion set "java_opts=-xms64m -xmx1024m -xx:maxpermsize=256m" set "java_opts=%java_opts% -dhttp.nonproxyhosts=*.company.com|localhost|127.0.0.1"  java.exe !java_opts! 

Comments