8

What are some good alternatives to Windows batch scripts? We have a number of them and they are very "clunky" to work with. As our group is familiar with Java is Groovy a good option?

A lot of our scripts are used to prep dev databases so they involve a lot of cd mydir, hg fetch, sqlplus ..., etc..

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429

5 Answers5

12

If you are interested in developing scripts for Windows than a technology developed specifically for Windows, like the PowerShell, is a sensible choice.

While groovy will probably allow you achieve your goal I don't think there is a particular advantage that it could offer.

Saying that, you have to consider familiarity factor and learning curve. You say developers have experience with Java and Groovy in which case running ant tasks via the groovy DSL can prove easier than learning PowerShell.

Regardless, consider developing your scripts using the TDD approach. Groovy offers plenty of frameworks (try Spock for example) while there are also ways to achieve that for PowerShell.

Community
  • 1
  • 1
mfloryan
  • 7,667
  • 4
  • 31
  • 44
2

Powershell, VBScript, Perl, Python. There are no shortages of good scripting languages that have a Windows implementation.

tloach
  • 8,009
  • 1
  • 33
  • 44
  • 2
    I tried Python. When starting a process you have to fiddle with streams, and as soon as you run into Unicode issues you'll find that Python is not the right tool for this job. Batteries not included. – Andreas Haferburg Nov 21 '18 at 20:31
1

PowerShell 2.0 onward is a good choice. It will come along with Windows Server 2008 R2 or windows 7 onward. you don't need to install anything on top of these O/S version.

1

It kind of depends on what you are looking to do with your scripts. BASH on windows via cygwin might be a good thing to try.

user605331
  • 3,718
  • 4
  • 33
  • 60
1

You might also wanna look at good old Ant, it has targets for copying, executing shell commands, etc. Gradle might be even better, as it supports inline Groovy code, including easy loops and conditions, which Ant lacks.

Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
  • I agree, that Gradle is a nice tool for this, but Groovy, using Grapes for dependencies is definetly also nice. – sbglasius May 27 '12 at 16:59