Results 1 to 2 of 2

Thread: Modify Permission to Home Folder Script

  1. #1
    Masti Guest

    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


  2. #2
    Al Dunbar Guest

    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



Similar Threads

  1. how to make application for changing/modify file permission
    By dinafrinsi in forum Software Development
    Replies: 1
    Last Post: 28-04-2012, 01:43 PM
  2. How to gain file permission to modify windows registry
    By Elettra in forum Operating Systems
    Replies: 5
    Last Post: 06-07-2011, 07:04 AM
  3. Home folder creation via script
    By CHRITOPHER in forum Active Directory
    Replies: 3
    Last Post: 15-12-2008, 10:39 PM
  4. Difference between Full control and Modify permission?
    By Praveen P in forum Windows Server Help
    Replies: 2
    Last Post: 11-12-2008, 03:44 PM
  5. Problem After Creating Home Folder with vbs script
    By Susan Bradley in forum Active Directory
    Replies: 3
    Last Post: 18-08-2008, 09:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,889,232.15611 seconds with 17 queries