Page 1 of 1 1
Topic Options
#178671 - 2007-08-03 09:59 AM RD /s doesn't seem to handle read-only directories.
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
Hi there,

It's seems that RD /s doesn't delete read-only directories.
Version 4.53

Can someone else confirm this?

Situation 1:
"C:\Temp\Test", Dir Test is read-only.

RD "C:\Temp\Test" /s
ErrorCode: 5 Access is denied.

Situation 2:
"C:\Temp\Test\Sub", Only Dir Sub is read-only.

RD "C:\Temp\Test\Sub" /s
ErrorCode: 145 The directory is not empty.

Manual says it deletes everything, like CMD.EXE's RD /q /s does.
I've tested it with, S and H attributes, and no problems. Only R attribute.

Thanx, Ryan

Top
#178674 - 2007-08-03 10:45 AM Re: RD /s doesn't seem to handle read-only directories. [Re: Ryan]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Odd, but yes confirmed.

RD "C:\TEMP" /S
Works correctly and removes all

RD "C:\TEMP\TEST" /S
Does not work. 5 Access Denied
It does remove any files in the folder but not that folder.

I will post in beta and point back here.

Top
#178676 - 2007-08-03 11:55 AM Re: RD /s doesn't seem to handle read-only directories. [Re: NTDOC]
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
He NTDoc,

Thanx for confirming and posting.

Looking forward on 4.60, nice features.

Grz Ryan

Top
#178680 - 2007-08-03 01:28 PM Re: RD /s doesn't seem to handle read-only directories. [Re: Ryan]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
According to the manual, there is no comparison to "RD /S /Q". Personally, I'd think this is expected behavior - items are marked read-only for a reason. If there isn't a /R switch, then it should not remove read-only items. Both Move and Del commands have specific switches to allow changing R/O files.

It might be a nice feature to have a /R switch added to the RD command, but I don't think this is a bug.

You can try something like:
 Code:
SetFileAttr($Folder, GetFileAttr($Folder) & 254)
Rd /S $Folder

to be sure the R/O attribute bit is turned off before you remove the folder.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#178683 - 2007-08-03 02:20 PM Re: RD /s doesn't seem to handle read-only directories. [Re: Glenn Barnas]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
 Quote:
items are marked read-only for a reason


such as being copied from a CD/DVD?
I'd say removing read only files is expected to work by default, as it works also with a shelled RD
_________________________



Top
#178690 - 2007-08-03 11:02 PM Re: RD /s doesn't seem to handle read-only directories. [Re: Jochen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Glenn, there is no /q switch but that's basically because KiXtart is not a batch file and we wouldn't really be interacting with it.

I've had a few e-mails and posts here with Ruud on this issue and it should work just fine, but it doesn't. Thus it is a bug (IMHO)

RD /S (fixed for 4.53) should remove all. I just never tested the exact same way as here.

RD "FOLDER" /S should remove everything regardless of file/folder attribute.

Top
#178691 - 2007-08-04 01:22 AM Re: RD /s doesn't seem to handle read-only directories. [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
what??? /q?? I never said Kix RD has a /Q argument..

The original post compared Kix RD to Cmd.exe's RD /s /q. I pointed out that the other Kix commands - Del and Copy - have specific switches to permit modifying file with Read-Only attributes, and that the manual does not compare Kix RD with CMD.EXE's RD function.

I'd expect the Kix RD to work the same way as the other built-in commands and require a switch to apply to R/O folder, just like Del requires a /R to delete read-only files.

Given the logic, if RD not deleting R/O folders is a bug, why is requiring a special switch for Del and Copy to modify R/O files not a bug? Seems to me that RD is outnumbered two Kix commands to one.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#178695 - 2007-08-04 01:46 AM Re: RD /s doesn't seem to handle read-only directories. [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
LOL - Okay sorry - thought you were implying something else.

Personally I don't care if it requires more switches or not just as long as it works. I don't think it should require any switches to be honest.

It should delete everything up to where you said remove, no question, no switches, just do it.

RD "C:\TEMP\FOLDER1\FOLDER2"
Should remove FOLDER2 and everything in it

RD "C:\TEMP"
Should remove TEMP regardless of what's in it

Thinking of what RD (Remove Directory) is for it doesn't really make sense to me to have an /S switch. If the directory is removed then obviously the other files and folders within are removed as well.
The only thing I think might be along those lines is if some file or folder is locked and then maybe have a switch to remove it upon reboot like DEL has.

Top
#178701 - 2007-08-04 03:38 PM Re: RD /s doesn't seem to handle read-only directories. [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
I kinda agree - if I run RD, I want it to remove all content regardless of FILE attribute, but if the FOLDER is marked RO, that's when I think it should require a /R switch.

I think I'm applying experience from environments outside of just Windows. Windows has always seemd Fast & Loose compared to *IX or mainframe environments.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#178709 - 2007-08-05 10:29 AM Re: RD /s doesn't seem to handle read-only directories. [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well I'm actually of the opposite feeling on that. I'm tired of utils that refuse to delete and you have to go back and double check or run more commands, etc.

I said REMOVE - I don't care what is left in there or what attributes it has, REMOVE IT. If I was concerned with the attributes then I'd probably be using a DEL command and paying more attention. RD (IMHO) is and should be a quit asking, just remove command. I don't need or want the underlying OS or other items trying to out think me and "ARE YOU SURE" me till I'm blue in the face. I took the time to code it up, YES I'M SURE.

/end rant

Top
#178712 - 2007-08-05 04:52 PM Re: RD /s doesn't seem to handle read-only directories. [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
LOL - but you forgot your <rant> tag! Can't stop what you didn't start! ;\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#178714 - 2007-08-05 05:47 PM Re: RD /s doesn't seem to handle read-only directories. [Re: Glenn Barnas]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: Glenn Barnas
Can't stop what you didn't start! ;\)
Yes he can... he's a board administrator.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (mole) and 1300 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.071 seconds in which 0.03 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org