How to use the command line and write in command language

Table of contents:

How to use the command line and write in command language
How to use the command line and write in command language
Anonim

To complete the steps in this article, first start Notepad; to do this, click Start> Run and type notepad. Minimize the Notepad window and open a command prompt; to do this, click Start> Run and type CMD.

Steps

Use the Command Prompt and Write in Batch Language Step 1
Use the Command Prompt and Write in Batch Language Step 1

Step 1. Understand what Notepad and the command line are

In Notepad, you can create a text file and save it in any format. The command line is for entering commands that control various functions of the system.

Right-click on the blue bar at the top of the Command Prompt window and select Properties from the menu. Now, in the Edit section of the General tab, check the box next to Quick Edit. Click OK. A window will open asking if you want to apply or save your changes. Check the box next to "Save settings for windows with the same name" and click OK

Use the Command Prompt and Write in Batch Language Step 2
Use the Command Prompt and Write in Batch Language Step 2

Step 2. Know what to do next

Most likely, now you think that your actions will damage the system - this is possible if you do not know what to do. So first learn how to navigate between directories.

  • Type CD c: \ and press ↵ Enter. You will change from the current directory to the root directory of the C: drive. Next, we will teach you how to display all files and folders that are in this directory.
  • Type DIR and press ↵ Enter. A list of files and folders will be displayed on the screen. In the last column, you will find the names of directories that branch off from the root directory of the C: drive (or from the directory you are currently in). If it's a folder, you'll see in the column to the left of the named column on the same row. If it's a file, you won't see it next to it, but you will find the file extension (*.txt, *.exe, *.docx) at the end of the file name.

Step 3. Create a folder where you will copy all your batch files

Enter MKDIR mybatch. The folder "mybatch" will be created. To test this, enter DIR again and locate this folder in the displayed list. 4.

Use the Command Prompt and Write in Batch Language Step 4
Use the Command Prompt and Write in Batch Language Step 4
Use the Command Prompt and Write in Batch Language Step 5
Use the Command Prompt and Write in Batch Language Step 5

Step 5. Remember how to use the "ping" command

If your computer is not connected to the Internet, skip this step. The "Ping" command sends data packets to the specified site and receives responses from the site; if so, the site is working fine.

For example, let's check if the site google.com is working. Type PING Google.com and press ↵ Enter. The screen will display something like "Reply from 72.14.207.99: number of bytes = 32 time = 117ms TTL = 234". There can be about four such lines. If an error message appears on the screen, either your internet connection or website is down. It will also indicate how many packets were sent, received and lost. If 0 packets are lost, the website is 100% up

Use the Command Prompt and Write in Batch Language Step 6
Use the Command Prompt and Write in Batch Language Step 6

Step 6. Run the program from the Windows / System32 folder

For example, enter mspaint.exe to start Paint. It is more difficult to open a program that is in a specific directory, as you did with Command Prompt and Notepad using the GUI.

Run the program or open the file that are in the directory. Go to the running Notepad and type Hello world !. Then click File> Save As, type Helloworld.txt in the File Name line, and save the file to the mybatch folder on your C: drive. Go to the command line and you will find yourself in the "Documents and setting" folder. Now type cd c: \ mybatch, press ↵ Enter, and then type helloworld.txt. Usually, you don't need to open the command line again, but this is a little more complicated because you don't go directly to the "C:" directory

Use the Command Prompt and Write in Batch Language Step 7
Use the Command Prompt and Write in Batch Language Step 7

Step 7. Create a "deleteme" folder in the "C: directory"". To delete a folder, use the RMDIR command. For example, enter RMDIR deleteme to delete the "deleteme" folder. This command removes files, folders and subfolders.

Tip: When using the RMDIR command, navigate to the folder with the file or subfolder you want to delete, and then enter RMDIR *, where instead of "*" enter the name of the file or folder to be deleted. Go to your C: drive and type RMDIR deleteme. The system will ask if you want to delete the folder. Press Y> ↵ Enter. This will delete the "deleteme" folder

Step 8. Rename the file or folder

To do this, use either of the two commands: REN and RENAME. Create a folder called “idon’tlikemyname” and then enter REN idon’tlikemyname mynameisgood. The folder will be renamed. Now you can delete it. 9.

Use the Command Prompt and Write in Batch Language Step 8
Use the Command Prompt and Write in Batch Language Step 8
Use the Command Prompt and Write in Batch Language Step 9
Use the Command Prompt and Write in Batch Language Step 9

Step 10. Understand batch programming and write the program in Notepad

You don't need to buy an expensive program for this - everything can be done for free. In notepad enter:

    @echo off Echo This is a batch file Echo that displays the time Echo Current time Time / t

  • Three suggestions will appear on the screen. At the same time, you will not see the commands themselves - this is thanks to the @echo off command. Without this command, the screen will display text and commands, for example, like this:

    Echo hello Hello

  • The time / t command will display the current time. Be sure to add the "/ t" parameter - otherwise the system will ask you to enter the time.
  • Click File> Save As, type Timefirst.bat for File Name, and save the file in the mybatch folder. Please note that you saved the file in BAT format and not as a text file (TXT file). This is a batch file format that does not work without the ".bat" extension.

Advice

To display a list of all commands, enter "help"

Warnings

  • If you don't know what you are doing, you could damage the system.
  • When using the DEL (or DELETE) command, remember that files / folders are deleted permanently, that is, they do not end up in the Recycle Bin.

Popular by topic