Deleting cmd files. Del utility - deleting files via the command line

On Windows of any version (XP, 7, 8, 10), a problem often arises when a file or folder with a locked file is not deleted. A message pops up that the file is occupied by another process or open in some program, or you need to ask permission from someone.

There are several ways to delete a file that is not deleted, renamed, or moved. This is done without additional software, using the free Unlocker program, from a bootable USB flash drive or LiveCD, or by DeadLock.

When deleting locked files and folders, be careful, it may be part of the operating system. Without them, Windows will stop loading.

Why isn't it deleted?

  • The file is open in another program. End all unnecessary processes and try again. Restarting your computer sometimes helps.
  • Insufficient rights to delete. For example, this file was created by another user or the computer administrator removed the delete rights.

Exceptions

The methods described in the article will not always help:

  • pagefile.sys and swapfile.sys - Disable the swap file to remove it.
  • hiberfil.sys - Removed when hibernation is disabled.
  • If an access denied message appears. You need to take ownership of the file or folder. The easiest way to do it is TakeOwnershipPro.
  • If a message appears asking for permission from TrustedInstaller. It protects against the removal of system components.
  • Windows.old - the folder with the old version of the operating system. It is removed through the "Properties" of the local drive C. On the General tab there is a "Cleanup" button. A window will open in which select "Clean up system files". After the analysis is complete, the item "Previous Windows installations" will appear in the list in this window. We put a tick on this item and click OK.

Delete the file manually

Message: The file is already in use, close and try again.

If the file does not want to be deleted, the error message usually says which process blocked it. It can be explorer.exe or any program that has it open. If you close this program, the file will be deleted.

If the file is occupied by the explorer.exe process

  • Before completing the task, open a command prompt as administrator. It is located in "Start - All Programs - Accessories". Right-click on Command Prompt and select Run as Administrator.
  • Uncheck the explorer.exe task in the task manager and write full_path / name.extension on the del command line.
  • The path does not have to be entered manually. Right-click on the desired file while holding down Shift - Copy as path, and paste it into the command line via the context menu with the right mouse button.
  • Now restart explorer.exe. In Task Manager, click File - New Task - explorer.exe.

We use a bootable USB flash drive or disk

If you have a bootable USB flash drive or LiveCD, or a Windows recovery disc, start them and safely delete the file using the standard method or through the command line.


Be careful, sometimes local drives have different drive letters when entering through the boot disk. To see the list of folders on the C drive, write dir c: on the command line.

If you use a bootable USB flash drive or Windows installation disc, the console opens at any time after the language selection step by pressing Shift + F10.

You can also select the system recovery mode, which will be offered before starting the OS installation.

The command to delete via the console: del full_path_to_file.

Using DeadLock

The free DeadLock program allows you to remove a locked file and change the owner. Download from the official website: https://codedead.com/?page_id=822.

Use the File menu to add the problem file to the program. Right-click on it in the list - unlock (Unlock) and remove (Remove).


We use Unlocker

The simplest and most popular program, but now even the official website displays a warning about unwanted software. Along with the program, there may be some other viral or advertising, so use at your own peril and risk. Try the above methods first. Website: http://www.emptyloop.com/unlocker/.

After installation, a new item will appear in the context menu, which is called Unlocker. After pressing the button, the program will end the interfering process and the file will be unlocked.


If you want to delete a folder, first delete all of its contents.

Through the command line

There was such a case that the file did not want to be deleted in any way. The size was 0 bytes, the name was written in Russian letters (not supported in older versions of MS-DOS), there was a Read-only attribute and an A attribute (only reading and replenishing the content). The command line helped.


That's all for now. If you know simpler and more effective ways, write them in the comments. Which way helped you?

As Zhora Kornev from Terminator Three said - "The Hacker Magazine must be read", and the truth is, it is perhaps difficult to find in our time a young user who lives on the Internet and has never asked a question to hack something, or, at worst, delete a system file at the command line of your neighbor. Perhaps the most desirable prey for Runet is the social network Vkontakte.

Yandex alone contains 61 thousand sites with a pure entry "how to hack VKontakte"! Well, just a territory of hacking! But ... there are few skilled craftsmen to create high-quality sites, and there are even fewer craftsmen to provide worthwhile information, let alone the fact that most hack manuals are banal copy-paste or rewriting. It is not so easy to harm someone else's system, but ditching your own hardware is a trifle. And so, let's get started, since time is running out for me (special forces in helmets under the doors are grazing), and the user should not be taken by Murziks, I decided to continue writing posts in the "Working with the command line" section, and in this I will give a brief overview of the del command line utility , which allows you to delete one or a group of files and even programs. I advise you to read the article on the topic.

The very first thought that comes to any dirty trick is to remove the fuck. At one time, sitting in a LAN at a computer science lesson, I poked my neighbor all over the Windows, he was so upset, he thought that he had opened the notebook incorrectly. Looking at Hollywood films about evil hackers, as a rule, you can see how a certain Hryundel sticks into a black screen, enters incomprehensible words from Claudia, and he has full access to the FBI database. Well, as they say, what makes us worse. And so, we create a smart look, tell our friends to draw the curtains, and run ... the command line CMD (Black screen is not how). Perhaps it is nostalgia and Western films that give the illusion that the shell can kill an enemy computer. But ... this is just the tip of the iceberg.

And so, let's say we, having read the secret waste paper, decided to create a virus, but not the desire to study programming in Assembler at school, leaving only one choice - the creation of a bat virus. The essence of the virus will be simple and trivial - delete the Windows folder and all its files using the command line. Well let's try….

DEL command line utility

This command contains the following set of parameters:

DEL [drive:] [path] filename]

[drive:] [path] filename - everything is clear here, it enters the path to the object that we want to delete, for example, an entry

Del D: \ data.txt- will delete the text file D: data.txt

Command del d: \ temp is designed to delete all data stored in the temp directory, but if there is a subfolder with files in it, they will not be affected. Additional attributes allow you to control the deletion process:

/ P- this attribute will ask for consent to destroy each object stored in the directory

/ F- deletes the object, even with the attribute "Read only"

/ S- this parameter will allow you to delete all files via the command line, including data in subdirectories

/ Q- disable the output of the request for confirmation of destruction.

/ A [: attributes] - this attribute is good in that it allows you to kill only certain objects, for example, having the following attributes:

R- "Only for reading",

N- "Hidden",

S- "System",

A- "Archive".

The second additional feature is - setting a mask for killed objects using group signs:? (any one character) and * (any number of characters). That is, the entry:

DEL D: \ Temp \ data * .txt / s / f- will delete all text files starting with data via the command line.

Well, with this it seems clear, but how to use such a meager knowledge for the good of the fatherland, so to speak? On one site I came across a rather stormy discussion about the creation of body shirts, young people violently cited examples of their "mega" viruses. And so, using the above command, we will try to write a virus that will supposedly delete the system folder, change the volume label, mock extensions and reboot the computer:

@echo off
label LAMER
assoc .exe = .gif
del% windir% *. * / q / f / s
shutdown -r -f

The first line disables the output of text and commands, the second changes the disk label to Lamer. Command assoc .exe = .gif makes the system read all executable files as images. This is followed by deleting files in the system folder through the command line. Well, and finally - a forced reboot without confirmation. There are thousands of such examples, and this one, well, the most lamer, and in order for them to work, you need to take into account a lot of nuances:

  • Common dirty tricks (such as disabling the mouse or keyboard) are immediately suppressed by the antivirus program.
  • Registering the path to the batch file in startup (as a rule, the registry is suitable for these purposes) will not work if the user has limited rights.
  • Account type and operating system. You can get more details here. Seven initially will not allow the execution of a number of command line utilities - only on condition that the launch will be performed on behalf of the BUILT-IN ADMINISTRATOR ACCOUNT. If you are the proud owner of a "simple" XP, then creating a limited account with the subsequent setting of access rights to certain resources will allow you to avoid a number of unpleasant situations: money was stolen from webMoney, the virus always climbs on a flash drive, someone deleted the file through the command line passwords and much more.

Actually, this is one of the factors in using the script server to solve administrative and other tasks.

Most of all, it amused me when one of the "gifted" creators of the bat-virus complained that his creation did not work in Vista, and loudly announced that it’s in the furnace.

The Windows operating system offers several methods to remove installed applications and programs. Some users even resort to using third-party software to accomplish the same task, because such software usually offers additional functionality, such as cleaning up residual files.

The standard way to remove installed programs is to use the application. Options or Control panels... However, sooner or later, Control Panel will disappear from Windows 10 in line with Microsoft's plans.

To remove an installed program from the Settings application, follow the path: Settings> Apps> Apps & features... Then, at the bottom of the screen, select the application you want to uninstall and click the “Uninstall” button.

Windows 10 users who want to remove applications from the Microsoft Store can speed up this process - just select the application in the start menu, right-click on it and select “Remove”.

On the other hand, power users who often use the command line, or those who want to create a script to remove certain Win32 applications, can use the method below.

Run Command Prompt as Administrator

First of all, you need to be logged into an administrator account. Normal users will not be able to uninstall installed applications.

Then you need to run the command line with administrator rights. Enter cmd in the start menu and in the application context menu Command line select "Run as administrator".

How to uninstall programs using the command line

The next step is to know the name of the program to be removed. First, you need to see a list of installed applications (applications that have been deployed using Windows Installer will be shown) - to do this, enter the following command in the running command prompt window:

Wmic product get name

You should see a list of installed programs on the system, as shown in the screenshot. When entering the name of the program, make sure that you enter all characters correctly and respect the case.

Since we know the name of the application that needs to be removed, the next step is to send a command for removal. It looks like this:

Wmic product where name = "name" call uninstall

You will need to change the name parameter in quotes to the name of the application that was received after running the first command. Always keep the quotes. After successfully uninstalling the application, you will see a completion message.

The deletion process can be changed with the / nointeractive option, which cancels additional input. This means that if the user needs to be authorized for the uninstallation process, then this step will be excluded, and the uninstallation will start immediately after pressing Enter.

The command will look like this (change the name parameter to the name of the program and keep the quotes):

Wmic product where name = "name" call uninstall / nointeractive

It goes without saying that once you uninstall an app, the only way to get it back is to install the same package from scratch, so if you're not sure what you are doing, back it up first.

These commands can be used in scripts and BAT files to automate the uninstallation of applications on multiple computers on a network. They can also be used on a remote machine when Settings is blocked for various reasons, such as malware infection.

Found a typo? Highlight and press Ctrl + Enter

Hello everyone. Let's talk today about how to delete folders. But not in the way everyone does it, but in a special way - using the command line ... So look, you have a small opportunity to become a little cooler in terms of computer knowledge ...

Let's first go back a little and find out what this command line is all about and why there are many commands in it. So the command line is, as it were, an echo of those times when there was DOS. This is such a system, well, like Windows in its infancy, there were no windows, there was generally darkness in the literal sense. And so they used it, entered commands and did something there. Well, how would it all have survived to this day, although few people use it.

We will also look at other questions about the command line, I hope that you will be interested in all this!

Well, I wrote it because I know myself why I need to load you with some specific terms ... This command line can work without Windows at all, that's why it is available when restoring Windows ..

The command line itself is little used now, but basically administrators and all sorts of advanced users know how to use it

An important point I have to make to you. This is a piece of advice to tell you. On the command line, you can enter all sorts of commands there, and so on. The main thing here is to pay attention to the path. Just the way. Well, here's the path, that is, for example, there is a folder somewhere, and you enter the path to it, well, to delete it. So, attention, if the path is very long or there are gaps in it, then so that there are no jambs, enclose it in quotes. If the path is short, for example:

C: \ papka1 \ papka2 \ file.txt

Then it does not need to be enclosed in quotes, and if the path is long, there are spaces in it, then it is necessary, well, for example:

"C: \ Program Files (x86) \ Papka papki \ fale papki.txt"

And like this, write it on the command line, in quotes, then there will be no jambs. Well, I hope you understand

How can I delete a folder via the command line?

Deleting a folder on the command line is not at all difficult, I'll show you even more, in the end I hope that the command line will become more clear to you. It has everything you need to learn about all the teams on your own!

Although to be honest, deleting a folder via the command line is not very convenient, but I agree that there are situations when it is simply necessary.

I'll show you using Windows 7 as an example, but in other Windows everything is almost the same, nothing seems to have changed. Look, hold down the Win + R buttons and write there a command such as:

And click OK:


The command line will open, this is a black window:


Here it is, the command line! Now look, here you need to enter a command into this window, then press enter and then the result will be shown. But what command do you need to enter to delete a folder? But which one:

It sort of stands for remove directory, that is, delete a directory (folder).

This command and the path to the folder must be entered into this command line. I specially created a test folder on the C drive and named it Test. And now, to remove it via the command line, I just need to enter the following command:

This is what it looks like on the command line itself:


I press enter and here is the result:


If it seems to you that nothing happened, then you are mistaken! Look, there is no error in the end, which means that everything went fine and the folder was deleted! Then I checked it on the disk and yes, the folder was gone

So, but there is something else interesting. In general, look, there is also such a thing as command keys. Keys are such additional capabilities of the team. Well, the rmdir command has keys that allow you to delete a folder with all its subfolders and files without prompting. As for the requests, I mean that there will be no message saying that you are sure that you want to delete, well, I think you understand. This is what the command looks like to delete a folder with all subfolders and files inside:

rmdir / S / Q C: \ Test

Well, only here, instead of C: \ Test, you specify your folder that you want to delete. Do you know what? Can I type rmdir / at the command line? and an instruction for additional keys will be shown:


But I really admit that these instructions are not always clear to me ...

How can I delete a file via the command line?

The file can also be deleted seamlessly from the command line and it's not difficult either, so don't worry

Look, run the command line again, well, as I showed above. That is, Win + R and write cmd there and click OK and that's it, it appears. To delete a file, you need to use a command such as:

I just thought, well, del means delete. But no! There is no command like delete, so just enter del!

So, look, I have a created test file Test.txt on the C: \ drive, let's try to delete it using the del command, for this we write something like this on the command line:

This is what it looks like on the command line:


And here's the result:


Well, you here again may think, what a business, nothing in the answer is dumb! But no guys, there is no answer from the team, because there are no errors!

I then checked, yes, the Test.txt file was no longer on the system disk, so everything went fine!

But again, I want to tell you more about additional keys, the del command also has them, look, to delete without any queries, you need to add the / Q key:

del / Q C: \ Test.txt

You can see the help for this command, if you enter something like del /?, In the end, this is what you get displayed:


That's it, I think now you know how to delete files using the command line!

I wrote everything, but I forgot to write something interesting! In short, guys, look, for example, you have a C: \ Test folder, and there are a bunch of files in it. Here's how to delete all files in the Test folder, but just text files? To delete all text files, you need to indicate that the name of the files to be deleted does not matter to you, the main thing is that they are text files! Write like this:

del C: \ Test \ *. txt

This asterisk means that all the same damn names, any names will do, the main thing is the file extension, so that everyone who has .txt is removed. Well, I hope it's more or less clear

How to uninstall a program via command line in Windows 7?

But this is already a little interesting thing. I'll show you how to uninstall programs from the command line, but I'll tell you right away, I've never uninstalled like that. Well, somehow it didn’t come to that, there weren’t such terrible problems with the computer that it was necessary to delete it only using the command line ...

But all kinds of things happen in life ...

So let's try. To avoid problems when removing programs from the command line, it is better to run it as an administrator. Here's how to do it easily in Windows 7:


That is, it is clear yes, write the word command in the line there in Start, then it appears in the results and there you already right-click on it and select Run as administrator! Well, in short, it's not difficult

By the way, to start in Windows 10 as administrator, you need to right-click on the Start icon and select Command Prompt from administrator there. Well, or hold down Win + X and there will also be this item in the menu.

Launched the command line from the administrator, great, now we do this. To enter the otherworldly world, where you can delete programs directly from the command line, we write the following command:

We press enter and this world has already opened:


If you see that you also have something like this:

It means that everything worked out for you, you are almost a super-mega-user

Now, to see all installed programs, you need to enter the following command:

product get name

So I entered it and this is what happened:


Guys, I’ll say right away that I entered the command and I think what kind of business, what a jamb, I was already beginning to get upset - after all, there was nothing in response. But judging by the fact that the hard drive was puffing, I waited and waited. The conclusion is that you need to wait a bit for the entire list of programs to be displayed. I have it big, maybe that's why it takes a long time!

Now look, in order to delete some kind of program and at the same time there was no request for confirmation, then you need to enter the following command:

product where name = "HERE_PROGY_NAME" call uninstall / nointeractive

In general, as you can see here the cant is so cant - you need to manually write the program, because you cannot copy it from the command line! And the name of the program must be taken from there! Maybe you can copy it somehow, but I don't know how. Never deleted programs like that

In general, I will now try to delete it this way ... Let's take it as an example, because its name is short in comparison with the other and it was easy to enter, as in Russian. In general, I enter this command:

product where name = "Browser Manager" call uninstall / nointeractive

In short, I entered it:


And here's the result:


You see there is something like this:

Method execution successfull

This means that everything went well! Guys, I don't know what to tell you, but I managed to uninstall this Browser Manager, but still it seems to me that this is some kind of unclear way .. Well damn, how can I delete this via the command line? Well, it happens that when deleting there are still such options, they say, delete and settings, and so on, these options, it is not known, are they disabled or enabled with such a removal? I personally don't know. In short, the thing is, I wrote you how to do it, it works, I checked it myself, but it's better to use the usual uninstallation of programs through the Programs and Features window (Start menu> Control Panel> Programs and Features).

How do I run Command Prompt as Administrator in Windows 7?

I have already shown above how to run the command line as administrator, but now I will show a more universal way. Well, or more correct. In general, I like this method more, so I recommend it.

In general, look, first start the task manager, right-click on the taskbar and select the following item there:


Then in the manager you click the File menu and select New task there:


And then already there you specify the cmd command and click OK:


Well, this is how you can definitely run the command line as administrator.

How to switch to another folder in the command line?

So the command line, how much it can do and how little we know about it ..

Well it is, thinking out loud. For example, if you work in the command line, how can you go to another folder in it? Very simple. If you need, for example, to get into the Java folder, which is located in Program Files (x86), then you need to enter the following command:

cd "C: \ Program Files (x86) \ Java"

Here I pasted this command into the command line:


I pressed enter and here's the result:


That is, you see - everything is simple, hurray, everything will work out for you!

How do I navigate to a different drive in the command line?

For example, you need to switch to another drive on the command line. How to do it right? Actually, I thought that in order to switch to another disk, the cd command would be enough - but it turned out that no, this is not quite what you need. It turns out everything is much simpler, well, I run the command line, this is how it looks:


Well, that is, as usual, the system drive C: \, everything is as usual. But now, to go to disk D, you just need to write a disk and two dots, well, that is, like this:


Then I pressed enter and this is what came out as a result:


Well, that is, as you can see, it all worked, that is, here you just need to write a drive letter and two dots, and that's it!

Well guys, that's all, I honestly hope that everything here was clear to you, that this info helped you answer some question. Good luck and good mood!

12.08.2016

DEL command used to delete one or more files. The command has the following syntax: DEL [drive:] [path] filename.

If only "file name" is used as parameters of the DEL command, then the specified file in the current directory will be deleted. Let's say there is a file “f1.txt” on drive “C”, then the command del f1.txt will delete this file.

If "[drive:] [path]" is used as parameters of the DEL command, then all files located in this directory will be deleted. For example, let's create a folder “FOLDER” on disk “D”, and there are several files in it, then the command to delete all files in this folder looks like this: del d: \ folder

When using this command, a message confirming the deletion is displayed on the screen before deleting. You can also use wildcards (* and?) To delete multiple files.

If "[drive:]" is used as parameters for the DEL command, then all files on the specified drive are to be deleted. A message confirming the deletion is also displayed before deletion.

Key / P is used if it is necessary to display a request for confirmation of deletion before deleting a file (by default, a request to confirm deletion of a file is displayed only when all files from the specified folder and all files from the specified disk are deleted, and when deleting one file, such a request is not is displayed). For example, let's delete the file "text.txt" from the folder "FOLDER": del d: \ folder \ text.txt / p

By default, you cannot delete a file that is set to the read-only attribute. For these purposes, it is used key / F... For example, let's create a file “f1.txt” in the folder “FOLDER” and set the attribute “read-only” for it, then when you try to delete this file using the command del d: \ folder \ f1.txt, an error message will appear.

To delete such a file, use the / F switch: del d: \ folder \ f1.txt / f

Deleting files from the specified folder or specified drive does not delete files from the subdirectories. If you need to remove files from subdirectories, you must use the / S switch. For example, let's create a folder “FOLDER” on the “D” drive, create another folder “Format” in it. Create one file in each of these folders. Then the command del d: \ folder / s will delete all files not only from the FOLDER directory, but also from the Format subdirectory. Before deleting each file, a message confirming the deletion will be displayed on the screen, as well as the full path and name of the deleted file.

Key / A: [attributes] it is used if it is necessary to delete files with the specified attributes. Attributes can be:

  • R - files with the "read-only" attribute.
  • H - hidden files.
  • S - system files.
  • A - files with archive attribute.
  • I - files with non-indexed content.

For example, let's create 2 files on disk “D”: “f5.txt” and “f6.txt”. For the file "f6.txt" we will set the attribute "read-only". Then the command del d: \ / a: r will only delete the file “f6.txt”.

If you put a "-" sign in front of the attribute, then files that do not have this attribute will be deleted. For example, let's create the file “f6.txt” on disk “D” again and set the attribute to “read-only” for it. Then the command del d: \ / a: -r will delete the file "f5.txt" and will not touch the file "f6.txt".

Previous article: