in reply to setting environment-variables
About foobar...
update: try this:
C:> perl -e "$a='foobar'; print 'set ZZZZ='.$a; " > foo.bat C:> foo.bat [download]