Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best free resource for learning advanced batch-file usage?

What are the best free resources for learning advanced batch-file usage?

like image 254
Brian R. Bondy Avatar asked Oct 07 '08 22:10

Brian R. Bondy


3 Answers

It's not free, but it's probably the best. "Windows NT Shell Scripting" by Tim Hill.

That said, whenever I try to do something 'advanced' in cmd batch files, I always end up regretting it.

Always.

edit: some explanation of the shortcomings of batch files:

  • math capabilities are pathetic
  • quoting support is an afterthought - if you need to pass a quoted string as an argument to a command that needs to be quoted itself, reserve a spot at the asylum (actually, I'm not sure it's possible)
  • string manipulation is a patchwork of half implemented functionality

Then there are the seemingly never-ending bits of oddities, corner cases, and inconsistencies that you run into at every turn.

The only thing going for batch files is that they're supported on every Windows box out there. If you just want to automate executing a few commands as a group, great. Maybe add a simple loop, a couple of subroutines, and some environment variables to parameterize things. Beyond that I strongly recommend you use something else.

like image 75
Michael Burr Avatar answered Sep 22 '22 22:09

Michael Burr


Also consider learning Windows Scripting Host as an alternative to batch scripting. You can use your choice of languages to write scripts (JScript, VBScript, even Python). It is supported by every modern version of Windows and provides a feature-rich library of functions that makes batch files look primitive in comparison.

What am I saying? Windows Batch files ARE primitive.

You can also create re-usable WSH libraries, modules, etc. There was a bit of a learning curve compared to batch files, but well worth it. No longer do my Linux friends make fun of my inferior scripting environment. Now they just make fun of my inferior OS.

like image 5
James Schek Avatar answered Sep 22 '22 22:09

James Schek


To get help on commands, this .bat file will put all commands' help into a nice HTML page: http://www.robvanderwoude.com/files/allhelp.zip

This guy has some other interesting .bat things as well. http://www.robvanderwoude.com/batexamples_a.html

like image 5
Denes Tarjan Avatar answered Sep 20 '22 22:09

Denes Tarjan