Need assistance in setting NTFS folder permissions with VBScript

I have the code below which I found on this and other Web sites and customized it to my needs. It creates a folder on a file server and shares it. However, the last thing I need to do is to add a specific user to the NTFS permissions and assign modify permissions. I want it to retain inherited permissions, but just want to add a user to the ACL and give him/her modify permissions. What is the best way to go about this? Thank you.
Option Explicit
'On Error Resume Next
Dim objFSO, objExcel, objSpread
Dim objNewShare, objWMIService, objUser
Dim strParentFolder, strSheet, strSam, intRow, strFirst, strLast
Dim strShareName, errReturn, strPathName, strComputer, strSharePath
 
Const FS = 0
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
strSheet = "c:\UsersWithHomeFolders.xls"
strComputer = "server"
strParentFolder = "\\" & strComputer & "\e$\Files\Users\"
 
' Check to see if spreadsheet exits
If objFSO.FileExists(strSheet) = False Then
  MsgBox("The file " & strSheet & " does not exist. Please create the file and run the script again.")
  WScript.Quit
End If
 
' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
intRow = 3 'Row 1 often contains headings
 
' Here is the 'DO...Loop' that cycles through the cells
' Note intRow, x must correspond to the column in strSheet
' Trim function eliminates blank spaces
Do Until objExcel.Cells(intRow,1).Value = ""
   strSam = Trim(objExcel.Cells(intRow, 1).Value)
   strLast = Trim(objExcel.Cells(intRow, 3).Value)
   strFirst = Trim(objExcel.Cells(intRow, 4).Value)
   strPathName = strParentFolder & strLast & ", " & strFirst
   strShareName = strSam & "$"
   strSharePath = "e:\Files\Users\" & strLast & ", " & strFirst
 
   If objFSO.FolderExists(strPathName) = False Then
      objFSO.CreateFolder strPathName 
     'this code creates the share
     Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
     Set objNewShare = objWMIService.Get("Win32_Share")
     errReturn = objNewShare.Create(strSharePath, strShareName, FS)
   End If
 
   intRow = intRow + 1
   
Loop
 
objExcel.Quit
 
Set objFSO = Nothing
Set objExcel = Nothing
Set objSpread = Nothing
Set objWMIService = Nothing
Set objNewShare = Nothing
 
WScript.Quit

Open in new window

mcpp661Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aherpsCommented:
0
Malli BoppeCommented:
You can use cacls to set permissions.
So you can write a batch script which calls this vbscript and next line you would be cacls which would set the permissions or you can run the cacls in the vbscript as well.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sirbountyCommented:
Modify this section of your code with the attached:

   If objFSO.FolderExists(strPathName) = False Then
      objFSO.CreateFolder strPathName
     'this code creates the share
     Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
     Set objNewShare = objWMIService.Get("Win32_Share")
     errReturn = objNewShare.Create(strSharePath, strShareName, FS)
   End If

   If objFSO.FolderExists(strPathName) = False Then
      objFSO.CreateFolder strPathName 
     'this code creates the share
     Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
     Set objNewShare = objWMIService.Get("Win32_Share")
     errReturn = objNewShare.Create(strSharePath, strShareName, FS)
     Dim objShell : Set objShell = CreateObject("Wscript.Shell")
     objShell.Run "cacls " & strSharePath & " /e /t /g YOURUSER:C"
   End If
 
Replace YOURUSER with the user account...

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

mcpp661Author Commented:
Is CACLS something that's included with Windows or is it an executable that needs downloaded?
0
Malli BoppeCommented:
No its included in the windows.
0
mcpp661Author Commented:
Well, in the script file do I have to include the path to CACLS? If so, do you know what the path is off the top of your head? Also, the folder permissions I want to set are on a file server but I'm going to run this script from my local workstation, does that mean the objshell.run line will have to be modified to reflect that?
0
Malli BoppeCommented:
The file is located in c:\windows\syatem32 so you don't need to specify the path.You need to modify the objshell.run ans speciify the UNC path of your file server.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.