Removing a folder or program from the command line

Removing a folder or program from the command line

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 certain 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

To achieve the goal, open cmd with administrator privileges. Enter RD /? and quickly familiarize yourself with the features and parameters of the command. Here you will see only 2 parameters:

  1. /s - when using this prefix, the folder will be deleted, as well as all its nested elements. If your directory is not empty, and you have not specified this parameter, then nothing will work for you.
  2. /Q - used when deleting without confirmation.

In general, the design looks like this:

RD or RMDIR /s/q “full folder path”

Note: when applying the design, the directory and its contents will be completely deleted from the computer and you will not find it in the trash. To be safe, make a backup copy of the folder.

Deleting a folder with or without confirmation

I created a directory on my computer called “cmd” and copied several objects into it. Then I entered the following command into the command line:

RD /s “c:cmd”

Then I pressed Enter and the Y key because cmd prompted me to confirm the deletion.

I checked the C drive and found no directory. Next, I created a folder named “delete” and also copied 5 files, but when entering the command, I removed the /s prefix. It turned out like this:

RMDIR “c:delete”

After pressing Enter, the deletion did not occur, and a message was displayed on the command line that the folder was not empty. Conclusion, without the /s parameter, you can only delete an empty folder, therefore, using it without this prefix is ​​practically useless.

If you are too lazy to enter the confirmation letter (Y or N), then the following construction is for you. The /q prefix was mentioned above; it is what removes the annoying typing of letters (see the screenshot for proof).

That's all, with these actions you can easily delete folder from command line, using a not at all complicated syntax. With cmd knowledge, your any ideas will turn into reality, with which you will even turn off the computer from the command line and do much more.

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

If only "filename" is used as parameters to 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 del f1.txt command 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 drive “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, before deleting, a deletion confirmation message is displayed on the screen. You can also use wildcard characters (* and ?) to delete multiple files.

If “[drive:]” is used as parameters to the DEL command, then all files on the specified drive will be deleted. Before deletion, a deletion confirmation message is also displayed.

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

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

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

Deleting files from the specified folder or specified drive does not delete files from subdirectories. If you need to delete files from subdirectories, you must use the /S switch. For example, let’s create a “FOLDER” folder on drive “D” and create another “Format” folder in it. Let's create one file in each of these folders. Then the del d:\folder /s command 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] 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 an archive attribute.
  • I – files with non-indexed content.

For example, let’s create 2 files on drive “D”: “f5.txt” and “f6.txt”. For the “f6.txt” file, set the “read-only” attribute. Then the command del d:\ /a:r will delete only 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 “f6.txt” file on drive “D” again and set the “read-only” attribute 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:

Recommendations will help you completely delete a folder via command line. In the article about, the DEL command was used, which is intended specifically for files. In the case of folders, the RD or RMDIR commands are applicable.

To achieve the goal, . Enter RD /? and quickly familiarize yourself with the features and parameters of the command. Here you will see only 2 parameters:

  1. /s - when using this prefix, the folder will be deleted, as well as all its nested elements. If your directory is not empty, and you have not specified this parameter, then nothing will work for you.
  2. /Q - used when deleting without confirmation.

In general, the design looks like this:

RD or RMDIR /s/q “full folder path”

Note: when applying the design, the directory and its contents will be completely deleted from the computer and you will not find it in the trash. To be safe, make a backup copy of the folder.

Deleting a folder with or without confirmation

I created a directory on my computer called “cmd” and copied several objects into it. Then I entered the following command into the command line:

RD /s “c:\cmd”

Then I pressed Enter and the Y key because cmd prompted me to confirm the deletion.

I checked the C drive and found no directory. Next, I created a folder named “delete” and also copied 5 files, but when entering the command, I removed the /s prefix. It turned out like this:

RMDIR “c:\delete”

After pressing Enter, the deletion did not occur, and a message was displayed on the command line that the folder was not empty. Conclusion, without the /s parameter, you can only delete an empty folder, therefore, using it without this prefix is ​​practically useless.

If you are too lazy to enter the confirmation letter (Y or N), then the following construction is for you. The /q prefix was mentioned above; it is what removes the annoying typing of letters (see the screenshot for proof).

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, write 1.bat in the file name line 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 “Previous Windows installations” and click “OK”. The message “Are you sure you want to permanently delete these files” appears? 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

A message will appear again 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 for forcibly deleting folders

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.

views