How To Delete A File From The Command Line

Table of contents:

How To Delete A File From The Command Line
How To Delete A File From The Command Line

Video: How To Delete A File From The Command Line

Video: How To Delete A File From The Command Line
Video: How to delete files and folders using Command Prompt in Windows 10 2024, November
Anonim

Windows Command Prompt is a powerful system management tool. With knowledge of certain system commands, you can perform almost any action with settings and files in Windows. With its help, you can also delete unnecessary system files or some data inaccessible to the graphical interface.

How to delete a file from the command line
How to delete a file from the command line

Instructions

Step 1

Run the Command Prompt utility in Windows. To do this, you can go to "Start" - "All Programs" - "Accessories" - "Command Line". To launch it, you can use the Windows keyboard buttons (the button with the Windows logo) and R at the same time. You can also find the console by entering cmd in the start menu search bar.

Step 2

In the window that appears, you must enter the desired command to delete your file. The del command is commonly used and has the following syntax:

del drive: path_to_file / file attribute

Instead of "disk" in this command, you must insert the letter of the drive on which the file you recorded is located. So, if the document to be deleted is located in the windows folder of the system drive, the command will look like del C: / Windows / file.txt, where file.txt is the file to be deleted.

Step 3

If you want to delete all data in a folder, specify the appropriate / S attribute. For example:

del C: / Windows / folder / s

This command will delete all data in the folder directory, including any subdirectories.

Step 4

You can also use the Erase utility to erase the files you want. It has a similar syntax to del and can also erase necessary files. For example:

erase C: / Program Files / Game RMDIR

This command will destroy the Game directory, which is located in the Program files directory of the C drive.

Step 5

There are two steps to remove a system file. First, you must indicate that you are the owner of this document:

takeown / f C: / Windows / System32 / program.exe

This request will help you get access to delete the program.exe file.

Step 6

Then you need to allow the delete operation on the system to yourself through the cacls command:

cacls C: / Windows / System32 / program.exe / G system_user_name: F

"User_name_in_system" is your username that is used when working in the system.

Step 7

After that, you can use the del query:

del C: / Windows / System32 / program.exe

The deletion of the system file is complete.

Recommended: