setting permission to the folder through VB script

Discussion in 'Meet and Greet' started by sathish81, Apr 2, 2012.

  1. sathish81

    sathish81 New Member

    Joined:
    Apr 2, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi ,

    Can anyone help me out in creating a VB script which can read the values from either text file or excel and set permission to the folder

    example in the excel or text pad


    File shared folder names
    Functional IDs
    Remarks
    Folder 1
    N566212
    Read access
    Folder 2
    k089663
    R/W access
    Folder 3
    N933229
    Full access
    Folder 4


    Folder 5


    Folder 6


    Folder7


    fdf


    asf


    asdfa




    Thanks in advance
     
  2. kickerr

    kickerr New Member

    Joined:
    Oct 7, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    It can be difficult creating a VB script that can do that. this may not be the best website for asking that. may i ask if you are trying any other sites?
     
  3. sathish81

    sathish81 New Member

    Joined:
    Apr 2, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    No..I am new to VBScript world..I dont have any other website .I found the below snippet to give permission to the folder ..its working fine If I give folder name,fucntional Id and Tyrpe access hardcoded in teh script file..I am trying to modify this to read frm text or Excell
    Code:
     
    ' Cacls.vbs
    ' Example VBScript to set Administrators permissions with Cacls
    ' Version 2.1 - September 2010
    ' ---------------------------------------------------------' 
    Option Explicit
    Dim strHomeFolder, strHome, strUser
    Dim intRunError, objShell, objFSO
    strHomeFolder = "C:\TestFolderStructure"
    Set objShell = CreateObject("Wscript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FolderExists(strHomeFolder) Then
    ' Assign user permission to home folder.
    intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " _
    & strHomeFolder & " /E /c /g O035378:F", 2, True)
       If intRunError <> 0 Then
       Wscript.Echo "Error assigning permissions for user " _
       & strUser & " to home folder " & strHomeFolder
       
       else 
       WScript.Echo " Functional Id mapped succesfully"
       
       End If
           
    End If
    WScript.Quit
    ' End of Cacls example VBScript
     
    F499581
     
    Last edited by a moderator: Apr 3, 2012

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice