can someone give a reccomendation on learning a batch files command?

October 9th, 2009
Posted by: admin

maybe y’all can give me a few of a simple batch file command?

By: a1ronnie22



Tags: , ,

This entry was posted on Friday, October 9th, 2009 at 00:05 and is filed under batch. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “can someone give a reccomendation on learning a batch files command?”

  1. mrdenny Says:

    Start with the DOS help command. It’s got a lot of info about the various commands that can be used via a batch file.

    For example the FOR command is used to take input and fetch through it row by row and do something with each row.

    For example here is a single line batch file which logs into each of my SQL Servers (as defined in the file machines.txt in the same folder) and runs a T/SQL command against each one (as defined in command.sql in the same folder).

    @for /F %%a in (machines.txt) do sqlcmd -S %%a -i command.sql -E

    Everything before the word do is the for command. Everything after the word do is the SQL command which is being run once for each machine name in the machines.txt file.

    Batch file scripting is a lost art which is extremly powerful.

    I’m sure that there are more sexy ways to have done this but probably not in a single line of code.

Leave a Reply