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!

Give or change "folder permission" to a user

Status
Not open for further replies.

ZeeNer

Programmer
Jun 2, 2002
38
0
0
CA
Hi again!

I have another little problem in finding "how to change permission" (in my exemple, to a folder).

All of my users have their own personnal folder. They must have all permission on that folder.

I have to write e *.Vbs script file to give all the access to a user.

I also have to write another *.Vbs script file to remove those permissions for the same user. (Because the user can be activate and disabled in some other script files)

So... Simple task maybe... But it's my "first touch" with VBScript and i found only some topic about it but nothing that clearly show how to change the access to a folder for a user. (The name of the user is maybe "YanF1005" and his folder "C:\Users\YanF1005". An easy way to do what i want must exist... But if someone can put me on a "track" i'll appreciate it ;)
 
Do a keyword search in this forum for xcacls

Hope This Help
PH.
 
Here is a sample that does what you are asking. You should be able to work from this as a starting point.

On Error Resume Next
Dim sFolder 'As String
Dim sDrive 'As String
Dim sXpath 'As String



sDrive = " d:\"
sFolder = "d:\Documents and Settings"
sXpath = "\\server\util\xcacls.exe"


set oShell = Wscript.CreateObject("Wscript.Shell")
Set oFso = CreateObject("Scripting.FileSystemObject")

' if the docs and settings directory doesn't exist, create it
If Not oFso.FolderExists(sFolder) Then
oFso.CreateFolder sFolder
End If

sFolder = oFso.GetFolder(sFolder).ShortPath & " "

'set the permissions on d:\documents and settings
oShell.Run "cmd /C " & sXpath & " "& sFolder & " " & " /E /G "&Chr(34)& "Power Users" &Chr(34)& ":RXE"
oShell.Run "cmd /C " & sXpath & " "& sFolder & " " & " /E /G Users:RXE"
 
their is a security dll available from microsoft to do this. it is a pretty useful dll as it allows you to change permissions on files folders etc but you can take it furthur and use the idea to change security on adsi entries,,,such as dns entries etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top