By Vivian / Last Updated April 6, 2022

Want to delete files folder remotely with CMD

 

 

Hello everyone, I'm trying to delete a folder on remote machines using CMD on Windows 10. I don't have exclusive rights to do everything I'd like to so I've only been able to come up with using CMD as an alternative.  I'm open to suggestions to try out. Any insight you all can provide would be much appreciated!  

- Question from Stack Overflow

How do I delete a folder remotely with CMD?

By using CMD to delete a folder on a remote computer on Windows 11, 10, 8, 7..., here we sort it out into 2 parts. The first part is about remote connection with Remote Desktop and the second part is about deleting folders remotely. Keep reading.

Part 1: Establish remote desktop connection

By using Remote Desktop to establish a remote desktop connection, it needs to be mentioned that 2 devices should be on the same LAN, otherwise you need to perform port forwarding.

Step 1. Step 1. In the PC that you want to control, click the “Start” button and go to “Settings” > “System” > “Remote Desktop”. Here you can see the PC name of this computer. Keep it in mind, as you need  to use it for accessing this computer

Remote Desktop

Step 2. Drag the slider to enable Remote Desktop. Then, click “Confirm”.

Confirm

Note: By default, any user who has an administrative account on the host PC is allowed to access it, thus you need to set a strong password for your administrative account.

Step 3. Search  “Firewall” in the Search box, choose Windows Defender Firewall, and click “Allow an app through Windows firewall”.

RDC

Step 4. Click “Change Settings” and Check Private and Public for Remote Desktop. Then, click “OK”.

OK

After enabling Remote Desktop and allowing the tool in the firewall, you can run Remote Desktop Connection to control the computer. 

Step 5. In the PC that you use to control another PC, input “remote desktop connection”, double click "Remote Desktop Connection" to open it.

RDC

Step 6. Now, you’ll in Remote Desktop Connection. Type the PC name or the IP address of the remote PC  and click "Connect". 

Enter IP of the Host Computer

Step 7. Then, you’ll be asked to input the password and user name and the password of the host PC to connect to it. After controlling the remote computer, you can take operations just like you were sitting in front of that PC.

Part 2: Delete folder remotely with CMD

Now the remote connection must be established successfully. Now follow me to delete a folder on a remote computer with CMD on Windows 11, 10, 8, 7. Here are 2 command lines listed.

  • Use del command to delete the folder

Step 1. On the host PC, search “cmd” in the search box and then right click on the option, choose “Run as administrator”.

Run as Administrator

Step 2. Now the Command Prompt windows will be shown. Enter the command

“del /s /q \\ComputerName\c$\windows\ccmcache\FOLDERTODELETE"

For example:

del /s /q \\ComputerName\c$\windows\ccmcache\FOLDERTODELETE\MyFile"

Delete File

  • Use rmdir command to delete folder remotely

Follow the steps above and then enter “rmdir /s /q \\server\share\subfolder\FOLDERTODELETE” in Command Prompt Window. (Replace “FOLDERTODELETE” with the folder name you want to delete)

RMDIR

AnyViewer: Easily delete folder on remote computer with CMD

By following the command line list above, now you must know how to use CMD to delete a folder on a remote computer with CMD. If you meet with some problems on remote connections with Remote Desktop or you don’t want to be limited to the same LAN, here we recommend an easy-operated and high-responsive remote access software-- AnyViewer, to help you smoothly get remote access.

There are many shortcuts in AnyViewer, such as CMD, Task Manager, and Shutdown with which you can run Command Prompt with one click. More importantly, the way to connect is fairly simple. You can get remote access with one click if you log the same AnyViewer account on 2 devices. Follow me to know how AnyViewer works.

Note: To remotely control a PC from an iOS device, you can try to use AnyViewer iOS version.

Download Freeware Win 11/10/8.1/8/7
Secure Download

Step 1. On the host computer, install and run AnyViewer; click "Log in" and click "Sign up".

Log in AnyViewer

Step 2.  Filling all necessary information to create an AnyViewer account and then you'll be logged in to AnyViewer.  

Free Edition

▣ Note:  The device will be assigned to the account automatically be assigned to the account you've logged in to. 

Step 3. On your local PC, log in to the same account of the remote PC and then go to "Device". Locate the distant computer, click it and choose "Remote control" to take full control of the PC. 

Devices

After you take over the computer remotely, you can click on “Operation”, and then click on “CMD”. After that, you can run CMD successfully and then enter the command line to delete the folder.

CMD

Conclusion

In this post, we list 2 ways how to use CMD to delete a folder on the remote PC. With the command line, the folder deleting could be achieved. If you run into some problems when you tend to RDP to the server or you are seeking a more convenient way to open CMD, you can also resort to AnyViewer.