How to use the command line and write in command language

Author: Gregory Harris
Date Of Creation: 12 August 2021
Update Date: 1 July 2024
Anonim
Windows Command Line Tutorial - 1 - Introduction to the Command Prompt
Video: Windows Command Line Tutorial - 1 - Introduction to the Command Prompt

Content

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

  1. 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.
  2. 2 Figure out 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.
    • Enter 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.
    • Enter 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 will see dir> in the column to the left of the named column on the same row. If it's a file, you won't see dir> next to it, but you will find the file extension ( *. Txt, *. Exe, *. Docx) at the end of the file name.
  3. 3 Create a folder where you will copy all your batch files. Enter MKDIR mybatch... The folder "mybatch" will be created. To check this, enter DIR again and locate that folder in the displayed list.
  4. 4
  5. 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. Enter 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.
  6. 6 Run the program from the Windows / System32 folder. For example, enter mspaint.exeto 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 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 enter cd c: mybatch, click ↵ Enterand then enter 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.
  7. 7 Create a folder "deleteme" in the directory "C:". To delete a folder, use the RMDIR command. For example, enter RMDIR deletemeto 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 the C: drive and type RMDIR deleteme... The system will ask if you want to delete the folder. Press the keys Y > ↵ Enter... This will delete the "deleteme" folder.
  8. 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. 9
  10. 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.

Tips

  • 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.