home | about | newsletters | contact | advertising | Shop | radio | membership | site map

Helping Normal People Get Their Geek On And Live The Digital Lifestyle

Free and Premium. Why Register?

Login: Password: Remember me

How To Make A Batch File

Posted Mar 10, 2008 by Jason Faulkner  

I have seen this question asked many times on the forums here at PCMech. Sometimes, what one takes for granted, makes others scratch their head so I figured this is worth a tip posting.

Suppose you wanted a batch file to simply print the name of your computer. The command you would run would be the following:

echo %computername%

Here is how to make the above command a batch file:

  1. Open Notepad (you can use any text editor, but I am going to assume Notepad).
  2. Type/paste the commands you want to be in your batch file.
  3.  Select File > Save As.
  4. In the dialog, browse to the location where you want to save the batch file.
  5. Change the “Save as type” option to “All Files (*.*)” and then enter the file name ending with “.bat”, for example: MyComputerName.bat
  6. Alternate to step 5, you can enter the file name “MyComputerName.bat” (including the quotes) and this will ignore the Save as type setting.
  7. Click Save.

There you have it. You should now have a batch file in all its glory.

Categories: Daily Tips

Feel Like a Turtle When It Comes to Today's Tech?

Our silver and gold membership programs provide the premium information you need to strap a rocket on and fly. Premium content, exclusive members-only newsletter, no advertising, offline access, and more. Get the Inside Scoop.

About the Author

Jason Faulkner is the man who brings you our daily tips. He is based in Atlanta, Georgia.

3 Comment(s)

  1. Luis R. said:
    3/11/2008 7:39 am

    Is there any difference with batch files with the .cmd extension?

    [Reply]

  2. Jason Faulkner said:
    3/11/2008 9:27 am

    In short, yes… it has to do with OS support. Always use a batch file where possible.

    Rather than me explain it, Wikipedia has done a good job:
    http://en.wikipedia.org/wiki/Batch_file

    [Reply]

  3. totalcontrol said:
    7/24/2008 1:41 am

    ok so we can make a batch file but how can we get windows to automatically open this batch file?

    [Reply]

    drake reply on August 7, 2008 11:11 pm:

    u go to [MY COMPUTER]and then u go to [DOCUMENTS AND SETTINGS] then go to [STARTUP]and then u place the file there and it will start up every time you start up the computer.

    [Reply]

1 Trackback(s)

  1. Windows Batch Script To Backup Data » PCMech on May 12, 2008

Post a Comment

Free Weekly Newsletter

Name:
Email:
 

Featured Product of The Week

Getting Started with Ubuntu Linux

Getting Started with Ubuntu Linux

Now Playing on PCMech Video

Feature ImageGoogle Chrome (Video)

Feature ImageHow-To: Mass Rename Files in Windows XP/Vista

See All Videos | PCMech Channel Youtube Channel