Rmdir fails to delete folder with admin access


chiuchimu

Member
Local time
11:21 PM
Posts
3
OS
win11 pro
I run win11 pro on a minis forum um690.

I am using Cobian Reflector to incrementally backup my documents which makes a lot of empty folders. I can easily delete these empty directories in File Explorer using context menu. I wanted to automate this in a batch file but found that these empty folders made by my backup program are not easy to delete by command line. I have tried RD "My \folder\path" and get access denied. I have tried changing the ownership from myself, Admin, to Everyone and also change their respective permissions to full control but still get Access denied. Oddly, RD "My \folder\path" /s will delete the folder(adding the /q flag makes it quite). The "/s" deletes subfolders and files so that implies that the folder was not empty but show hidden files is checked and properties shows 0 files, 0 bytes and 0 folders in file explorer.

Although this works, it deletes empty subfolders which I don't want to happen because it is a backup. I just want empty folders in current directory deleted and empty folders that are down deeper in other directories left alone.
 

My Computer My Computer

At a glance

win11 proamd
OS
win11 pro
Computer type
PC/Desktop
Manufacturer/Model
minis forum/um690
CPU
amd
Screen Resolution
4k
Have you removed inheritance? I have to remove it first to be able to do anything.
Code:
takeown /s %computername% /u %username% /f "%SystemDrive%\Users\Public\Desktop" /r /d y
icacls "%SystemDrive%\Users\Public\Desktop" /inheritance:r
icacls "%SystemDrive%\Users\Public\Desktop" /inheritance:e /grant:r %username%:(OI)(CI)F /t /l /q /c
 

My Computer My Computer

At a glance

Home26H2CanAMD Ryzen 5 8600G (07/24)2x32GB Kingston FURY DDR5 5600 MHz CL36 @5200...ASROCK Radeon RX 6600 Challenger D 8G @48FPS ...
OS
Home26H2Can
Computer type
PC/Desktop
CPU
AMD Ryzen 5 8600G (07/24)
Motherboard
ASROCK B650M-HDV/M.2 (07/24) BIOS 4.21 AGESA ComboAM5 1.3.0.1 (04/26)
Memory
2x32GB Kingston FURY DDR5 5600 MHz CL36 @5200 CL36 (07/24)
Graphics Card(s)
ASROCK Radeon RX 6600 Challenger D 8G @48FPS (08/24)
Sound Card
Creative Sound BlasterX AE-5 Plus (05/24)
Monitor(s) Displays
24" Philips 24M1N3200ZS/00 (05/24)
Screen Resolution
1920×1080@165Hz via DP1.4
Hard Drives
Kingston KC3000 NVMe 2TB (05/24)
ADATA XPG GAMMIX S11 Pro 512GB (07/19)
PSU
Seasonic Core GM 550 Gold (04/24)
Case
Fractal Design Define 7 Mini with 3x Noctua NF-P14s/12@555rpm (04/24)
Cooling
Noctua NH-U12S with Noctua NF-P12 (04/24)
Keyboard
HP Pavilion Wired Keyboard 300 (07/24) + Rabalux 76017 Parker (01/24)
Mouse
Logitech M330 Silent Plus (01/26)
Internet Speed
500/100 Mbps via RouterOS (05/21) & TCP Optimizer
Browser
Edge, Brave for YouTube, LibreWolf for FB
Antivirus
NextDNS blocking 1/3 Traffic
Other Info
Phone: Motorola Moto G86 (02/26)
Backup: Hasleo Backup Suite (PreOS)
Headphones: Sennheiser RS170 (09/10)
Chair: Huzaro Force 4.4 Grey Mesh (05/24)
Notifier: Xiaomi Mi Band 9 Milanese (10/24)
FlexCore USB-C 3.2 Gen 1 (M) to LAN (F) (08/25)
After thinking about this problem, I can come up with only one answer:
If your chosen backup solution is not working, then try something else. There are actually many.

I like doing Data Backups because they are Quick and as easy as plugging in my Data Backup Flash drive, and running a little batch file.
In that batch file I use "XCOPY" (old DOS command) to do my backups. With a wide range of switches, it can do just about any kind of data backup you want.

I really like its ability to just back up the new files and ignore the old files that have already been backed up.
Regular Data backups, usually only take a few seconds.

Just a thought!
TM :cool:
 
After thinking about this problem, I can come up with only one answer:
If your chosen backup solution is not working, then try something else. There are actually many.

I like doing Data Backups because they are Quick and as easy as plugging in my Data Backup Flash drive, and running a little batch file.
In that batch file I use "XCOPY" (old DOS command) to do my backups. With a wide range of switches, it can do just about any kind of data backup you want.

I really like its ability to just back up the new files and ignore the old files that have already been backed up.
Regular Data backups, usually only take a few seconds.

Just a thought!
TM :cool:
Thanks for reply. I can delete the folder thru explorer, robocopy so I believe xcopy will use the same method. Basically my Mickey Mouse work around is to move everything onto itself with the subfolders flag "/s" included( ie; Robocopy /my/folder/path /my/folder/path /s /move). It works but deletes every empty folder including subfolders which I don't want it to do. Also I prefer to fix it properly; it is some setting/property that I can't access or nobody knows how to access - seriously, I search the whole internet. I have tried this on three computers, my um690 running win11 pro, SER5 win11pro and a win10 machine and this access denied problem happened all computers. Anyone can duplicate this problem. I might have to try writing my own code with my very limited programming ability.
 

My Computer My Computer

At a glance

win11 proamd
OS
win11 pro
Computer type
PC/Desktop
Manufacturer/Model
minis forum/um690
CPU
amd
Screen Resolution
4k
Update. This strange issue seems to have cleared it self. I've been workin on this issue for a week and just today I retried Rmdir and it worked. I even used a simple:

for /d %d in (.) do rd "%d"

and it work on two of my machines. Now I just have to turn this into an EXE and my backup solution is complete. I think the issue was a windows update because it solved itself. I had an issue with win updates breaking my system by crashing my AMD GPU driver but an update 3 weeks later fixed the issue - it started with 3/1/2023 update and ended around 3/25/2023 update . I think a similar thing happened here. I'm posting this in case someone else runs into same issue.
 

My Computer My Computer

At a glance

win11 proamd
OS
win11 pro
Computer type
PC/Desktop
Manufacturer/Model
minis forum/um690
CPU
amd
Screen Resolution
4k
Now I just have to turn this into an EXE
If you mean use something like Bat2Exe then do note that what they do is create a self-extracting archive file [much like WinZip can] then, when you run it, it extracts the batch file then runs the batch file.

All the best,
Denis
 

My Computer My Computer

At a glance

Windows 11 Home x64 Version 25H2 Build 26200....
OS
Windows 11 Home x64 Version 25H2 Build 26200.8037
Back
Top Bottom