Deleting a folder

Deleting a folder

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 is 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 flash drive or LiveCD, or the DeadLock program.

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. Terminate any unnecessary processes and try again. Sometimes restarting the computer helps.
  • Insufficient permissions to delete. For example, this file was created by another user or the computer administrator removed the deletion rights.

Exceptions

The methods described in the article will not always help:

  • pagefile.sys and swapfile.sys - to remove, disable the swap file.
  • hiberfil.sys - deleted when hibernation mode is disabled.
  • If an access denied message appears. You need to become the owner of the file or folder. The easiest way to do this is with the TakeOwnershipPro program.
  • If a message appears asking permission from TrustedInstaller. This is protection against the removal of system components.
  • Windows.old - a folder with an old version of the operating system. It is deleted 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.” Once the analysis is complete, the “Previous Windows installations” item will appear in the list in this window. Check this box and click OK.

Deleting the file manually

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

If a file doesn't want to be deleted, the error message usually tells you which process has locked it. This could 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 Command Prompt as an administrator. It is located in “Start - All Programs - Accessories”. Right-click on Command Prompt and select Run as Administrator.
  • Remove the explorer.exe task in the task manager and write del full_path/name.extension in the command line.
  • The path does not have to be entered manually. Right-click on the desired file while holding Shift - Copy as path, and paste it into the command line through the right-click context menu.
  • Now restart explorer.exe. In the task manager, click "File - New task - explorer.exe".

Use a bootable USB flash drive or disk

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


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

If you use a bootable USB flash drive or Windows installation disk, the console opens at any time after the language selection stage, using the key combination Shift + F10.

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

Command for deleting via the console: del full_path_to_the_file.

Using DeadLock

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

Using the File menu, add the problematic file to the program. Right-click on it in the list - unlock it (Unlock) and delete it (Remove).


Using Unlocker

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

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


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

Via 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 adding content). The command line helped.


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

You can delete a folder by right-clicking on it and selecting delete in the context menu. But sometimes this method does not help and I cannot delete the folder, so I will describe several ways to delete the folder.

Deleting a folder using the command line

To delete the Windows folder, do the following. Click “Start” - “All Programs” - “Accessories” - “Command Prompt”. A window will appear in which if you add Help and press “Enter”, a list of commands and a description of each command will appear, the RMDIR command is deleting a folder via the command line. To find out how to write the command you need, for example deleting a folder, you need to add Help RMDIR. The system told us how to write a command to delete a folder. RMDIR [drive:]path. I want to delete the remains of the game paradise in the RAI folder and I got this command. RMDIR /S /Q C:\Games\RAI.

Delete a folder via command line

Press “Enter” and the folder will be deleted immediately.

Deleting a folder using the bat file command

So we found out what the command to delete a folder looks like. There are folders that appear again after some time. To remove them, you can create a BAT file on your desktop because this folder, which we do not need, will be deleted when you run the bat file.

How to make a bat file

Right-click on an empty space on the desktop and select “Create” - “Text Document” from the context menu. Open this text document that appeared on the desktop. Enter the command RMDIR /S /Q C:\Games\RAI there, where C:\Games\RAI is the path to your folder. The entire path must be in English because the bat file will not run if there are words in Russian in the written bat file. Now click “File” - “Save As”. In the window that appears, in the file name line, write 1.bat and click “Save”.


In 1.bat rename the file

An example bat file will appear on your desktop. Now run 1 bat file and bat delete the folder instantly.

Removing the Windows old folder

Some install the system without formatting the disk and they end up with a folder with old Windows system files, usually called this Windows old folder. Many people do not know that the Windows old folder can be deleted. You can delete the old windows folder by using Disk Cleanup in Windows 7. Click “Start” - “All Programs” - “Accessories” - “System Tools” - “Disk Cleanup”. A window will open in which you need to select the drive on which the Windows old folder is located and click “OK”. The disk will be scanned and a window will appear in which we click “Clean up system files.” In this window, check the box for “Previous Windows installations” and click “OK”. A message will appear saying “Are you sure you want to permanently delete these files?” click “Delete files”.

Removing windows old

System files will be deleted from the Windows old folder and now you can simply delete the Windows old folder.

Delete a folder with administrator rights

Sometimes the folder is not deleted and the message “You need permission to perform this operation” appears. In order for the folder to be deleted, you need to allow full access in the folder properties. To do this, do the following. Right-click on the folder and select “Properties” from the context menu. Go to the “Security” tab and click “Advanced”. In the new window, go to the “Owner” tab and click “Change”.


We will change the owner of the folder

The owner window will open in which you need to select your administrator name (but not administrators), check the box “Replace owner of subcontainers and objects” and click “Apply”.


Changing the owner of a folder

In the message that appears, we confirm and become the owner of this object. From the “Owner” tab, go to the “Permissions” tab and click “Change Permissions”. In the window that opens, select the name of your administrator and click “Change”. A window will open in which we put a tick in the “Full access” item and click “OK”, this window will close, and in the open window we put a tick in the following items:
"Add permissions inherited from parent objects."
“Replace all permissions of the child object with permissions inherited from this object” and click “OK”.


Allow full access to the folder

Again a message will appear with which we agree by clicking “OK” and close all windows by clicking “OK”. Now the folder can be deleted.

Deleting a folder in Total Commander

It's very easy to permanently delete a folder in Total Commander. You need to find the folder you need to delete and click on it with the left mouse button, and then click the delete button at the bottom of Total Commander or press F8 on the keyboard and a message will appear in which we click “Yes” or “Delete”, depending on whether the folder is empty or there is something in it that is.


Finding and deleting empty folders in total commander

The folder will be deleted along with all its contents.

Program to force folder deletion

I like the Unlocker folder deletion program.

Install and the program for deleting non-deletable folders will be in the context menu. Right-click on the folder to be deleted and select Unlocker from the context menu. A window will appear in which set the action to “Delete” and click “Unblock all”. The folder will be deleted.

I make backups every day; dozens of gigabytes of information accumulate. It needs to be cleaned, especially since old backups are not particularly important. I used to delete it manually, but then I thought about it... I’m too lazy to do it manually, especially since you can plug, blunt and delete the wrong thing. In short, the lazy will do better than everyone else - we need to automate.

Used the built-in utility forfiles. Now everything is done by the task scheduler and a simple bat nickname in two lines. An example follows.

forfiles commands. Examples

This is what the command looks like to display all files with the .rar extension on drive C that are older than 10 days:
forfiles /p C:\ /m *.rar /s /d -10 /c “cmd /c echo @path”

Let's look at the keys in order:

/p - let it be for testing. In the example, drive C:\
/m - search mask. You don't have to specify this if you want to remove all files in the folder. In the example, all archives with the extension .rar
/s - scan subfolders as well.
/d - date. Can be specified in the format dd.mm.yyyy or dd. We have -10 days, you can specify +N days. Read more about +N days.
/c - command. The key thing we need is what we will do with the files. You can also use variables in commands:
@path - shows the full path to the file and its name.
@relpath - shows the path to the file only in the scanned folder.
@file - full file name with extension.
@fname - only the file name, without extension.
@ext is just the file name extension.
@isdir - checking the file type - folder or file. Returns true if a folder, false for files.
@fsize - Returns the file size in bytes.
@fdate - returns the date the file was last modified.
@ftime - returns last modified time file.

Also, the results of script execution can be written to a file.

An example of using forfiles is to display all .zip files on disk and write them to a file

The following code will display all your executable files:
forfiles /p C:\ /m *.exe /s /c “cmd /c echo @path”

If you need to write them to a file, then add a MORE sign at the end and the address where to save the file (it is best to write the full path).
forfiles /p C:\ /m *.exe /s /c “cmd /c echo @path” > D:\all_exefiles.txt

Paste the code into cmd:

The result is the created file on the D:\ drive and its contents (you can find a lot of interesting things):


Forfiles example with path, date, size variables

Let's call all our files from the D:\ drive with the .zip extension, and display them on the screen with address, date and size file. We use the script:

forfiles /p D:\ /m *.zip /s /c "cmd /c echo @path changed @fdate and size @fsize bytes"

Here is the result of running the script:


How to delete files older than 10 days

Most often, forfiles is used specifically for the task of removing outdated files. There you are cmd script to delete old files(in the example older than 10 days):
forfiles /p C:\ /m *.rar /s /d -10 /c “cmd /c del @path /q”

How to delete folders older than 7 days using forfiles

In addition to the files themselves, it would be a good idea to delete folders, especially if they are empty (without files). Code:
forfiles /p C:\downloads /s /d -7 /c “cmd /c rmdir /s del @path /q”
In this example, I have already written 7 days. To delete folders we use rmdir, the /s key is to scan subfolders, del is the delete command, /q is to delete without confirmation.

This lesson will show how to delete a file via command line in Windows(7, 8, XP, Vista). The DEL or ERASE commands will help with this, which are used when you cannot delete a file in the usual way. For , DEL and ERASE are not suitable.

Naturally, for starters. With this action you will get the best results.

If you use this lesson, then the file will be deleted immediately without being sent to the trash.

In cmd type DEL /? and press Enter to preview the command options. If you did it correctly, you will see an explanation (screenshot below).

Using cmd when booting Windows

Sometimes it becomes necessary to go into cmd before starting the system. If the malware is blocking successful login or the boot sector of the system is damaged, then the following steps will help you:

  1. Open Command Prompt when Windows boots
  2. In cmd enter DiskPart and press Enter
  3. Next you will need to write list volume and press enter again (see screenshot below). This will allow you to see the drive letter where you want to delete the file.
  4. After receiving the information, type exit and click Enter.

Now feel free to enter the options for the removal commands, which are described below.

With these steps you will delete any file on your computer using the command line.

Deleting a specific file

To delete a specific element, you need to know its name and extension. Otherwise, the likelihood of deleting the wrong thing increases!

In cmd, enter the following command and press enter:

DEL /F /S /Q /A "Full path of the element with extension"

For example, if I want to delete with the name “delete” and with the extension (.bat), located on drive C in the “trash” folder, I need to enter the command:

DEL /F /S /Q /A "C:\trash\delete.bat"

Delete all files with and without confirmation from the command line

In this case, you must confirm or deny the actions with letters (Y - yes / N - no) to delete all files in the main directory and subfolders.

To confirm, use this syntax:

DEL /F /S /Q /A "Full path to the folder\*"

If I need to delete all the files on drive D from the Trash folder, which contains many other directories and files, I would use the command:

DEL /F /S /Q /A "D:\add to cart\*"

In order to delete file from command line with confirmation, /P is added to the parameters and looks like this:

DEL /P /F /S /A "D:\experiment\*"

It is possible to delete all files with a given extension, then the command will look like:

DEL /F /S /Q /A "Full path to the folder\*.extension"

It is especially useful when there are a lot of unnecessary elements of the same type that are not an option to sort through manually, but can simply be deleted in batches from cmd.

With the right approach, you can delete file via command line, in a few seconds. I hope the recommendations were helpful. If you are interested in cmd, I advise you to read the material, which will be no less interesting.

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

The standard way to remove installed programs is to use an application Options or Control panels. However, sooner or later the Control Panel will disappear from Windows 10 according to 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 remove and click the “Delete” button.

Windows 10 users who want to remove applications from the Microsoft Store can speed up this process by simply selecting the application in the start menu, right-clicking on it and selecting “Delete”.

On the other hand, advanced users who frequently use the command line or those who want to create a script to uninstall specific Win32 applications can use the method suggested below.

Run Command Prompt with Administrator Rights

First of all, you need to log into your administrator account. Users with normal rights will not be able to remove installed applications.

Then you need to launch the command prompt with administrator rights. Enter cmd in the start menu and in the application context menu Command line select “Run as administrator”.

How to remove programs using the command line

The next step is to know the name of the program you want to remove. First, you need to look at the list of installed applications (applications that were deployed using Windows Installer will be shown) - to do this, enter the following command into the running command prompt window:

Wmic product get name

You should see a list of programs installed 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 to remove it. 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 obtained after running the first command. The quotation marks must be preserved. Once the app has been successfully uninstalled, you will see a message informing you that the operation is complete.

The deletion process can be modified using the /nointeractive option, which disables additional input. This means that if the uninstall process requires user authorization, this step will be omitted and the uninstall 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're doing, make a backup first.

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

Found a typo? Highlight and press Ctrl + Enter

views