Nathan Campos
Nathan Campos

Reputation: 29497

Resources To Learn About Batch Files

In my new project I need to use batch files(many of them), but now I need to know about they and where can I read some good tutorials to use they very good ;)

PS: I need to distribute my application for end-users.

Upvotes: 4

Views: 2156

Answers (7)

Joey
Joey

Reputation: 354566

Well, learning by doing is probably the best way. There are many pitfalls and weirdnesses in the batch language, making some tasks very much non-fun to do. But I think one should at least stepped into each trap once :-)

References are for example (sometimes with extensive examples for specific usage scenarios):

Specific problems and solutions may be found on sites like Rosetta Code but there aren't many (and I still didn't get around cleaning up there; the batch examples are horrible). I maintain a few tricks on my own site as well (currently under maintenance, though; struggling with my syntax highlighter).

Others have mentioned it: If you have the option, then by all means use other technologies. PowerShell is a nice one but not included by default on older Windows systems, including Vista. For many more complex tasks VBScript via WSH is usually a better option as it has a similar installed base and is way more powerful.

Depending on your requirements this may or may not be possible, but take it into consideration if it may be an option.

Upvotes: 3

Ken White
Ken White

Reputation: 125708

On Windows, use Start|Help and Support Center, and search on "Using batch files", and then in the list of topics under "Overviews, Articles and Tutorials" in the Suggested Topics, click on "Batch files". You'll find links to using parameters, filters and redirection, as well as reference links for batch commands like CALL, ECHO, FOR, and so forth.

The one advantage of batch files over PowerShell is that PowerShell may not be installed, while the command processor (CMD.EXE, or the older DOS version COMMAND.COM) will definitely be there.

Upvotes: 0

Jason S
Jason S

Reputation: 189686

While I usually don't like MSDN, in this case its documentation on batch files seems fairly decent.

Upvotes: 2

Stuntbeaver
Stuntbeaver

Reputation: 700

Basically with bat/cmd files you are running DOS commands (with extra programs/features available to Windows) with each command on a new line.

The .cmd extension is prefereable to .bat on older Windows systems as it runs with cmd.exe, which executes faster than the older command.com. On newer systems (XP and above I think) then it doesn't matter if it is .cmd or .bat then they get executed by cmd.exe.

Here's some tips/examples on writing batch files: http://www.ericphelps.com/batch/

Wikipedia has a list of DOS commands here: http://en.wikipedia.org/wiki/List_of_DOS_commands

Here's some info on invoking the actual cmd.exe http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true

Upvotes: 1

Vitaly
Vitaly

Reputation: 2585

Besides everything that was suggested, I can recommend using VBScript (.vbs). To use Powershell, you need to install it (although it might be installed along with Windows Updates). To use VBScript (which is also very powerful) you don't need anything, it's in Windows by default.

Upvotes: 0

Travis
Travis

Reputation: 12379

The one thing I can recommend if you're working with batch scripts in Windows is learn PowerShell. It's a souped up command line that will allow you to interact with any .net object.

Have fun!

Upvotes: 0

Mark Byers
Mark Byers

Reputation: 838276

You can start with: Command Line = PowerShell / bash / zsh / ...

Batch is very old-fashioned and practically obsolete now.

Upvotes: 0

Related Questions