Running a .bat file

  • I've a .bat file saved on the server but I'm not sure how to run it from cmd prompt. Will double clicking on the file run it instead of running it from the cmd prompt?

    Thanks everyone.

  • You can do it either way. If you double click on it, after execution the command prompt window will close (unless there is a PAUSE command in the batch file). If you open the command prompt and execute it, you would be able to see the output or error messages if any.

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • To run a .bat file from the command prompt, simply open your command window. to open the command window, I use Start > Run type cmd & press ok. (on early versions of windows use command instead of cmd).

    Then you just need to type your path & filename and press enter.

    If the path contains spaces then you need to enclose the whole thing in quotation marks.

    For example, the following is entered with quote marks:

    "c:\Documents and Settings\myUserName\My Documents\BatchFileName.bat"

    The following does not need quote marks:

    c:\temp\BatchFileName.bat

    NOTE: A shortcut to typing the whole file and path is to just drag the batch file into the open command window. Your file and path will be automatically entered with the quotes!!

    After you have entered the file path & name, just hit enter. That is all you need to do.

    One note - if you run a .bat file from the command prompt (as above) the command window will not close after your batch file has completed.

    If you want the command window to close afterwards, just run it like the earlier post from Adiga, double-click the file.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply