The DOS Call Command

DOS call command prompt

Well, DOS scripting is not dead. Today, I had another reason to jump down to the DOS prompt and write a little scripting code. Basically, I was attempting to automate an installation which had several pieces and this was the easiest avenue to completion. Dusting off old DOS command knowledge, I figured out that I could create a master batch file, which called the other installation files in the correct sequence. Using the DOS call command worked just like making a subroutine call. Here is an example, in case you need to do the same.

  1. Drop to a DOS prompt:
    • Start menu | Run | CMD
  2. Create the master batch (called bat1.bat):
    • Notepad bat1.bat
    • echo “this is another test”
    • call bat2.bat
    • echo “a test of bat1”
    • File menu | Save menu item
    • File menu | Exit menu item
  3. Create the file you want to call (called bat2.bat):
    • Notepad bat2.bat
    • echo “this is a test”
    • echo “a test of bat2”
    • File menu | Save menu item
    • File menu | Exit menu item
  4. Test your new nesting batch:
    • (your still in the DOS prompt)
    • bat1
  5. Check your results:
    • The first batch should initiate.
    • Any commands prior to the “call” should run.
    • Then, the second called batch should run in its entirety.
    • Control returns to the first batch, and any remaining commands after the “call” should run.

Since I had to complete some repetitive installations on several machines, and wanted the results to be identical, scripting in DOS saved me some time and also ensured the work was completed in a consistent manner. Hope this tip helps you in the near future. DOS is not dead!