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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To Get File permission in VB

Status
Not open for further replies.

cdls

Programmer
Sep 7, 2001
15
0
0
AU
Hi,
I need to get permissions associated with a file in VB.
I can use Cacls command in Command prompt and re-direct the output to a file.
For eg:
cacls c:\test.doc > c:\permissions.out

A file called permissions.out gets created and the permission information for test.doc gets written into this file.

But the same statement does not work when I use
Shell("cacls c:\test.doc > c:\permissions.out") in my VB code. permissions.out file does not get created.
I tried the same in run command( start->run).Here also I gave
cacls c:\test.doc > c:\permissions.out
but it did not work.

Any idea how to pass parameters and to re-direct the output using such commands using Shell function in VB?
Or is there any other function(VB or Windows API) which will return the Access Control List(ACL) associated with a file or folder?

Thanks for reading this.
 
create a batch file and put the command in it then shell the batch file or set a reference to Microsoft scripting runtime then dimension an object as FileSystemObject and obtain file properties that way
 
I have had this problem before. Try shelling out:
"cmd /c cacls c:\test....................."
 
Thanks a lot to both of you. It did work when I put cmd /c before cacls command.
Thanks again.
Your answers were very useful to me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top