19
readers helped!

This helped me

How to Use the Command Prompt and Write in Batch Language

To start you are going to need to have two programs open. One of them is Notepad. You can access it by clicking Start > Run... > Notepad. Minimize that and open the Command Prompt. You can access that at Start > Run... > CMD.

Steps

  1. How.com.vn English: Step 1 Know about Notepad and Command Prompt.
    Notepad isn’t any old text-editing program, because when you save it you can add any extension. Command Prompt or CMD is like DOS but it has loads more functionality.
    • So at the Command Prompt to make things easier to use you need to right click at the blue bar at the top and select properties. Under the Tab options you need to make sure QuickEdit Mode is enabled. Click OK. A box will appear to say if you want to apply them or save them. Click on the box saying ‘Save properties for future windows with the same title’. Click OK.
  2. How.com.vn English: Step 2 Learn about what it can do.
    You might think at this point that it is going to ruin my system. It can if you have no idea what you are doing. So to start, you need to know how to navigate between directories.
    • Type CD c:\ then hit Enter. You will have noticed that you have gone from your documents and settings directory to your C drive's root directory. If you follow the following instructions, you are going to see every file and folder that is in that directory.
    • Type DIR and hit Enter. Now you should see a long list. The rows of text in the last column tells you the names of the directories branching from the root directory (the top) of your C drive or in any other case, the directory you are currently in. If it is a folder, you will see <dir> in the column left of the name column in the same row. If it is as file it will not have <dir> next to it and will have a file extension (*.txt, *.exe, *.docx) at the end of the name.
    Advertisement
  3. How.com.vn English: Step 3 Make a directory to put all the batch files you are going to be making.
    Type MKDIR mybatch. You just ordered windows to make a new directory or folder called mybatch. If you want proof it is there type DIR again and look around. You should see it as a DIR.
  4. How.com.vn English: Step 4 Learn how to use the ping command.
    If you don’t have Internet connection you can skip this part but if you do you need to know it. Ping means to send packets of data around a website and it to return back to you. If it does it means the website is working and is alive.
    • You are going to test the Google search engine as an example. Type PING Google.com then hit Enter. You should see something saying like ‘Reply from 72.14.207.99: bytes=32 time=117ms TTL=234.’ It might have this about four times. If it says that it cannot ping your Internet connection isn’t working or the website is dead. It will also say how many packets it sent, received and lost. If it lost 0, the website is working 100%.
  5. How.com.vn English: Step 5 Open a program from the Windows Directory and System32.
    This is easy. Just type something like mspaint.exe and it will open the paint program. It is harder to open a program within a directory and you already did this using the user interface when you opened Command Prompt and Notepad earlier.
    • The way to open a file or program from inside a directory is harder. Assuming you still have notepad open type hello world. Then click File > Save As > Helloworld.txt in mybatch folder in your C directory. Reopen Command Prompt and you will be in your documents and setting folder. Now type cd c:\mybatch, hit Enter and then type helloworld.txt .You will not normally need to open Command Prompt again but it makes it a little bit more challenging because you don’t normally start in the C directory.
  6. Step 6 Make a DIR called "delete me" in your C directory.
    To delete a directory you need to use the RMDIR command. For example, RMDIR deleteme basically means "delete the directory named "deleteme". Even though the command is RMDIR, it will work with files as well as sub-directories or folders.
    • A little tip: when using the RMDIR command, navigate to the directory that contains the file or sub-directory you would like to delete, and then type RMDIR * with * being the name of the file or sub-directory you want to delete. Navigate to the C drive then type RMDIR deleteme. Then it will ask if you are sure you want to delete the directory. Type Y for yes and then hit Enter. You have just deleted the folder called "deleteme".
  7. How.com.vn English: Step 7 Rename a file or folder.
    You can use any of these two commands; they are both exactly the same, REN and RENAME so make a directory called "idon’tlikemyname" then type REN idon’tlikemyname mynameisgood. You have just renamed the directory. Now you can delete it.
  8. How.com.vn English: Step 8  Learn about batch programming and do it in Notepad.
    You do not need to buy expensive software for something you can do for free. In Notepad type:
      @echo offEcho this is a batch fileEcho I can tell the timeEcho tell the timeTime /t
    • You have just told it to echo three sentences. This is writing that will be shown on the screen. @echo off means that you won’t see on the screen the commands because if you did it would say:
    • Echo helloHello
    • The command time /t tells you the time! You must put "/t" or it will want you to change the time.
    • Go to File > Save As > (Save it in your mybatch folder) called Timefirst.bat. Notice that is has been saved as a bat file and not text. Don’t get confused and called it Timefirst.batch because it will not work.
    Advertisement

Community Q&A

Search
Add New Question
  • Question
    How do I make a new line?
    How.com.vn English: Community Answer
    Community Answer
    You press the enter button to go on to the next line.
  • Question
    How do I change my username in CMD?
    How.com.vn English: Community Answer
    Community Answer
    Simply type "netplwiz" into the command prompt window for GUI. You can also try: wmic useraccount where name='' the new name you want to use. For example: "wmic useraccount where name='administrator.'"
  • Question
    How do I type two lines in Command Prompt?
    How.com.vn English: Community Answer
    Community Answer
    copy con batch.batdir /w 'first commanddir /p 'second command^z 'ctrl-z' to save the fileC:>BATCH ' run the file
See more answers
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit

      Advertisement

      Video

      Tips

      • There are other commands to the ones listed, so just type help to learn more.
      Advertisement

      Warnings

      • If you don't know what you are doing you can seriously mess up your machine.
      • When using del (or delete) to delete files, be aware that they are permanently removed from the computer without ever going into the trashcan and cannot be recovered.
      Advertisement

      About this article

      How.com.vn is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 37 people, some anonymous, worked to edit and improve it over time. This article has been viewed 377,993 times.
      How helpful is this?
      Co-authors: 37
      Updated: June 30, 2021
      Views: 377,993
      Thanks to all authors for creating a page that has been read 377,993 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement