Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lookup file permissions 1

Status
Not open for further replies.

scriggs

IS-IT--Management
Jun 1, 2004
286
GB
I have a script which deals with moving files, etc.

Some of the files do not have write permissions.

Is there a function which:
a) can check permssions
b) change permissions

Any help plesae.
 


Take a look at the FileSystemObject Object.

Skip,

[glasses] [red]Be advised:[/red]When Viscounts were guillotined just as they were disclosing where their jewels were hidden, it shows to go that you should...
Never hatchet your Counts before they chicken! [tongue]
 
I think Im already using the FileSystemObject but cannot find how to check permissions on the file.
 
If GetAttr("c:\yourfile.txt") And vbReadOnly Then
MsgBox "File is Read-only"
'set to normal
SetAttr "c:\yourfile.txt", vbNormal
'copy the file here
'set back to read-only
SetAttr "c:\yourfile.txt", vbReadOnly
Else
MsgBox "File is not read-only"
End If

for more info, search VBA Help for 'SetAttr'
 
Thanks BiGiX, thats a useful script, which I'll add to my VBA snippets.

However I am interested in NT file permissions and ownership.
 
>cannot find how to check permissions on the file

The Attributes property of the FileSystemObject's File property ...

If you want the NTFS permissions, it's a touch harder
 
BiGiX!

You are awesome - that script worked 100% without any mods. Just changed the filename to a variable and slipped into my code. And it works ace!

Thanks so much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top