Posted By

laurenceosx on 04/22/13


Tagged

groovy


Versions (?)

Disguise a groovy script as a windows batch file hack


 / Published in: DOS Batch
 

I created this to make windows batch programming less painful.

  1. @ECHO OFF
  2. REM = ''' // dummy groovy statement in above line and dummy groovy assignment to dummy string var rem
  3. SET _JAVA_OPTIONS=
  4. SET CLASSPATH=
  5. groovy "%~dp0%~nx0" %*
  6. GOTO :EOF
  7. '''
  8. interface ECHO {} // dummy groovy interface/annotation to make groovy interpreter ignore first line
  9. // ### end of shared batch and groovy code hack ###
  10.  
  11. println "### Hello World from Groovy"
  12. System.exit(0); // Tested a variety of exit values and it was properly passed back to cmd

Report this snippet  

You need to login to post a comment.