Got more questions? Find advice on: ASP | SQL | XML | Regular Expressions
in Search
Welcome to WindowsAdvice Sign in | Join | Help

Steven Smith

Windows Tips and Tricks

Windows Batch File Commands

Wrote a batch file just now to do some DB setup for a Whidbey application that needs some ASP.NET features like Membership and Personalization.  So it has to call aspnet_regsql.exe a few times.  I used to write a lot of UNIX shell scripts, so I forgot what the comment character was for .bat files (hint, it wasn't '#').  In fact, it's not a character at all, but the lovely 'REM'.  Found this handy reference which includes the allowable commands:

  • @
    • Do not echo this line
  • ECHO
    • Send messages to user
    • Turn on/off output to user
  • REM
    • Comment out a line (short for remark)
  • PAUSE
    • prints "Press any key to continue..." and waits
  • GOTO
    • branches to a label
  • IF
    • can be used to check if a file exists or if a command returned an error
  • SHIFT
    • shifts command line params (useful if you have a lot of them I guess)
  • CALL
    • run another batch file from this one; allows reuse
  • FOR
    • allows looping
  • CHOICE
    • Prompts the user with a menu of choices and accepts one

Obviously I'm not offering a ton of syntax here -- go to the reference for that.

Published Wednesday, March 30, 2005 4:08 PM by ssmith
Anonymous comments are disabled