Rmdir fails to delete folder with admin access


chiuchimu

New member
Local time
2:13 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

System One

  • 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

System One

  • OS
    Windows 11 Home
    Computer type
    PC/Desktop
    CPU
    AMD Ryzen 5 3600 & No fTPM (07/19)
    Motherboard
    MSI B450 TOMAHAWK 7C02v1E & IFX TPM (07/19)
    Memory
    4x 8GB ADATA XPG GAMMIX D10 DDR4 3200MHz CL16
    Graphics Card(s)
    MSI Radeon RX 580 ARMOR 8G OC @48FPS (08/19)
    Sound Card
    Creative Sound Blaster Z (11/16)
    Monitor(s) Displays
    24" AOC G2460VQ6 (01/19)
    Screen Resolution
    1920×1080@75Hz & FreeSync (DisplayPort)
    Hard Drives
    ADATA XPG GAMMIX S11 Pro SSD 512GB (07/19)
    PSU
    Seasonic M12II-520 80 Plus Bronze (11/16)
    Case
    Lian Li PC-7NB & 3x Noctua NF-S12A FLX@700rpm (11/16)
    Cooling
    CPU Cooler Noctua NH-U12S@700rpm (07/19)
    Keyboard
    HP Wired Desktop 320K + Rabalux 76017 Parker (01/24)
    Mouse
    Logitech M330 Silent Plus (04/23)
    Internet Speed
    400/40 Mbps via RouterOS (05/21) & TCP Optimizer
    Browser
    Edge (No FB/Google) & Brave for YouTube & LibreWolf for FB
    Antivirus
    NoAV & Binisoft WFC & NextDNS
    Other Info
    Headphones: Sennheiser RS170 (09/10)
    Phone: Samsung Galaxy Xcover 7 (02/24)
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:
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
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

System One

  • 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

System One

  • 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

System One

  • OS
    Windows 11 Home x64 Version 23H2 Build 22631.3447
Back
Top Bottom