|
| ||||||||||
| Tags: modify, permission, script |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Modify Permission to Home Folder Script
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 |
|
#2
| |||
| |||
| 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 |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Modify Permission to Home Folder Script" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to make application for changing/modify file permission | dinafrinsi | Software Development | 1 | 28-04-2012 01:43 PM |
| How to gain file permission to modify windows registry | Elettra | Operating Systems | 5 | 06-07-2011 07:04 AM |
| Home folder creation via script | CHRITOPHER | Active Directory | 3 | 15-12-2008 09:39 PM |
| Difference between Full control and Modify permission? | Praveen P | Windows Server Help | 2 | 11-12-2008 02:44 PM |
| Problem After Creating Home Folder with vbs script | Susan Bradley | Active Directory | 3 | 18-08-2008 09:33 PM |