Changing the ACL on a folder through Wscript.Shell within VBA
CodeReview

Why use the Scripting.FileSystemObject?  MyFolder is just returning the folder name 


  MyFolder = Worksheets("Config").Range("D4").Value &amp; ActiveSheet.Range("C21").Value


I would also write a function to return the folder path and a second function to create the icacls commands.

Fun Part: My Own Solution

The class below will create a self-deleting batch file.  Running it in silent mode will hide the command window.  The advantage of using a batch file is that you can add a pause that will allow you to inspect the results of your commands.  

Note: pause will have no effect in silent mode and the files do not delete themselves immediately but they will automatically delete after a short time.





Class: BatchFile

Attribute VB_Name = "BatchFile"

Option Explicit
Public FileText As String
Private Const DeleteCommand As String = "DEL ""%~f0"""

Public Sub AppendLine(Text As String)
    If Len(FileText) &gt; 0 Then FileText = FileText &amp; vbNewLine
    FileText = FileText &amp; Text
End Sub

Public Sub AddICacls(ByVal FolderName As String, ByVal Parameters As String)
    AppendLine "icacls " &amp; Chr(34) &amp; FolderName &amp; Chr(34) &amp; Parameters
End Sub

Public Sub Execute(SilentMode As Boolean)
    Dim FilePath As String
    FilePath = getTempBatchFileName

    CreateFile FilePath

    Dim oShell As Object
    Set oShell = CreateObject("WScript.Shell")

    If SilentMode Then
        oShell.Run Chr(34) &amp; FilePath &amp; Chr(34), 0
    Else
        oShell.Run Chr(34) &amp; FilePath &amp; Chr(34)
    End If

    Set oShell = Nothing
End Sub

Private Sub CreateFile(FilePath As String)
    Dim Text As String
    Text = FileText &amp; vbNewLine &amp; DeleteCommand

    Dim FileNumber As Long
    FileNumber = FreeFile
    Open FilePath For Output As FileNumber
    Print #FileNumber, Text
    Close FileNumber

    Debug.Print Text
End Sub


Private Function getTempBatchFileName() As String
    Dim n As Long
    Dim FilePath As String

    Do
        n = n + 1
        FilePath = Environ("Temp") &amp; "\" &amp; n &amp; ".bat"
    Loop While Len(Dir(FilePath)) &gt; 0

    getTempBatchFileName = FilePath
End Function




Usage

Sub RunICalcs()
    Const DebugMode As Boolean = True

    Dim Batch As New BatchFile
    Dim FolderName As String
    FolderName = getFolderPath

    Batch.AddICacls FolderName, " /r /d y"
    Batch.AddICacls FolderName, " /setowner mydomain\admin"
    Batch.AddICacls FolderName, " /grant mydomain\StudentExam101:(OI)(CI)F /T"
    Batch.AddICacls FolderName, " /grant mydomain\DAdmins:(OI)(CI)F /T"
    Batch.AddICacls FolderName, " /grant mydomain\admin:(OI)(CI)F /T"
    Batch.AddICacls FolderName, " /grant SYSTEM:(OI)(CI)F /T"
    Batch.AddICacls FolderName, " /grant CREATOR OWNER:(OI)(CI)F /T"

    If DebugMode Then
        Batch.AppendLine "pause"
        Batch.Execute False
    Else
        Batch.AppendLine "pause"
        Batch.Execute True
    End If
End Sub

Function getFolderPath() As String
    getFolderPath = Worksheets("Config").Range("D4").Value &amp; ActiveSheet.Range("C21").Value
End Function