Modify Permission to Home Folder Script
Hi,
I have created this script and for some reason the script assigns only full
permssions to user home folder i am not able to assign only Modify permission
.. what i need is give Adminsitrator full access and user modify permission
only instead of full access .
Can you please check and let me know what i am doing wrong in this script .
option explicit
dim i
dim Fol
dim objFSO
dim objFolder
dim colSubFolders
dim objSubFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
for i = 1 to 2
If i = 1 Then
Set objFolder = objFSO.GetFolder("\\Storage Location1")
Else
Set objFolder = objFSO.GetFolder("\\Storage Location2")
End If
for each objSubfolder in objfolder.SubFolders
If objSubFolder.Name = "praveen" then
'MsgBox objSubFolder.Path
SetPermissions objsubfolder.Path, objSubFolder.Name
End if
next
next
msgbox "done"
Function SetPermissions(strHomeFolder, name)
Dim strHome, strUser
Dim intRunError, objShell, objFSO
'strHomeFolder = "C:\Test"
'MsgBox strHomeFolder
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strHomeFolder) Then
intRunError = objShell.Run("%COMSPEC% /C Echo Y| cacls " _
& strHomeFolder & " /E /C /G " & name & ":M ", 2, True)
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " _
& strUser & " to home folder " & strHomeFolder
End If
End If
End Function
Any help would be appreciated.
Thanks
Masti
Re: Modify Permission to Home Folder Script
"Masti" <Masti@discussions.microsoft.com> wrote in message
news:6C7C8262-0252-423A-9406-5D2481FD6E04@microsoft.com...
> Hi,
> I have created this script and for some reason the script assigns only
> full
> permssions to user home folder i am not able to assign only Modify
> permission
> . what i need is give Adminsitrator full access and user modify permission
> only instead of full access .
> Can you please check and let me know what i am doing wrong in this script
> .
>
> option explicit
>
> dim i
> dim Fol
> dim objFSO
> dim objFolder
> dim colSubFolders
> dim objSubFolder
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> for i = 1 to 2
> If i = 1 Then
> Set objFolder = objFSO.GetFolder("\\Storage Location1")
> Else
> Set objFolder = objFSO.GetFolder("\\Storage Location2")
> End If
>
> for each objSubfolder in objfolder.SubFolders
> If objSubFolder.Name = "praveen" then
> 'MsgBox objSubFolder.Path
> SetPermissions objsubfolder.Path, objSubFolder.Name
> End if
> next
> next
>
> msgbox "done"
>
> Function SetPermissions(strHomeFolder, name)
> Dim strHome, strUser
> Dim intRunError, objShell, objFSO
> 'strHomeFolder = "C:\Test"
> 'MsgBox strHomeFolder
> Set objShell = CreateObject("Wscript.Shell")
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> If objFSO.FolderExists(strHomeFolder) Then
> intRunError = objShell.Run("%COMSPEC% /C Echo Y| cacls " _
> & strHomeFolder & " /E /C /G " & name & ":M ", 2, True)
>
> If intRunError <> 0 Then
> Wscript.Echo "Error assigning permissions for user " _
> & strUser & " to home folder " & strHomeFolder
> End If
> End If
> End Function
>
> Any help would be appreciated.
Is intRunError being given a non-zero value? and, if not, are any error
messages being produced?
Regardless, I would change this part:
> & strHomeFolder & " /E /C /G " & name & ":M ", 2, True)
to this:
> & strHomeFolder & " /E /C /G " & name & ":C ", 2, True)
cacls /? states that it is no modify permission, but "Change (write)", and
the options are as follows:
/G user:perm Grant specified user access rights.
Perm can be: R Read
W Write
C Change (write)
F Full control
What I do not know is if the ":M" is somehow being interpretted as meaning
":F", such that CACLS is assigning this elevated access, or if the folders
were perhaps created for you with that permission for the owner by MMC and
ADU&C, and the error in your CACLS command is causing it to simply leave the
permissions unmodified.
/Al