objectivescott Posted March 12, 2005 Share Posted March 12, 2005 I need to have my script check a folder to ensure it is writable before the script attempts to write data files there. Does anyone have a good way of doing this already? Up to this point, I've been using the FileOpen code and getting its return value of -1 if the folder is not writable. The problem with this is, the script must create a file there first in order to give me this answer. I would like a clean way of checking a folder for writablility. Any thoughts? -S. Williams Link to comment Share on other sites More sharing options...
AutoElectric Posted March 12, 2005 Share Posted March 12, 2005 (edited) Can't you just erase the file after words? ;Folder Write-Protection Checking example by AutoElectric $Folder = TheFolder $Protected = 1 $Handle = FileOpen($Folder&\Test,2) If $Handle <> -1 then FileDelete($Folder&\Test) $Protected = 0 EndIf I don't see any other solution. Maybe there is a command line tool that will check it but it is not of my knowledge. Edit: Appearantly the forum does not allow font styles to be embedded within code tags. Edited March 12, 2005 by AutoElectric From the book of AutoElectric"Do not accuse another man, without proof, or you too will be accused", Morals 4:21The book of AutoElectric is MY book of morals, and follows biblical teachings. Link to comment Share on other sites More sharing options...
Alterego Posted March 12, 2005 Share Posted March 12, 2005 (edited) Maybe there is a command line tool that will check it but it is not of my knowledge.Yes it's called 'attrib' Would just manually setting the folder to writeable work?RunWait(@ComSpec & ' /c attrib -R',@DirectoryYouWantToCheck,@SW_HIDE) Edited March 12, 2005 by Alterego This dynamic web page is powered by AutoIt 3. Link to comment Share on other sites More sharing options...
MHz Posted March 12, 2005 Share Posted March 12, 2005 (edited) Yes it's called 'attrib' Would just manually setting the folder to writeable work?RunWait(@ComSpec & ' /c attrib -R',@DirectoryYouWantToCheck,@SW_HIDE)<{POST_SNAPBACK}>The Autoit inbuilt functions maybe more suited, to the task? FileGetAttrib ( "filename" ) FileSetAttrib ( "file pattern", "+-RASHNOT" [, recurse] ) Edited March 12, 2005 by MHz Link to comment Share on other sites More sharing options...
Alterego Posted March 12, 2005 Share Posted March 12, 2005 and there ya' go.... This dynamic web page is powered by AutoIt 3. Link to comment Share on other sites More sharing options...
objectivescott Posted March 12, 2005 Author Share Posted March 12, 2005 (edited) and there ya' go.... <{POST_SNAPBACK}>Thanks guys. The thing is...the folder may not even be available. For example, the folder may reside on a server which is currently offline or unavailable. Attrib will not work for this. That is why I was careful to say "writable"...as opposed to "have write permissions".Creating a file and then deleting it afterwards is a little silly and unclean I think. Edited March 12, 2005 by objectivescott Link to comment Share on other sites More sharing options...
Alterego Posted March 12, 2005 Share Posted March 12, 2005 (edited) I'm not following. If you are able to create a folder on a computer you are absolutely able to check the attributes of folders on that computer as well... Edit: able to create a file Edited March 12, 2005 by Alterego This dynamic web page is powered by AutoIt 3. Link to comment Share on other sites More sharing options...
AutoElectric Posted March 12, 2005 Share Posted March 12, 2005 (edited) I thought it was attrib, but I didn't seem to see the relation ship between non-writtable and read only. I thaught write-protected folders were set by some other means. Edited March 12, 2005 by AutoElectric From the book of AutoElectric"Do not accuse another man, without proof, or you too will be accused", Morals 4:21The book of AutoElectric is MY book of morals, and follows biblical teachings. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now