Hi ,
I've an app which needs to create three folders say name,root and system on C:\ drive and needsto give modify permissions to the user ofr these 3 folders can u help me how to write a script using cacls. I'm new to scriptting.I tried to write a script but its not executing.
0 Comments   [ + ] Show comments


Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

All Answers

Try this

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")

MY_FOLDER1 = "c:\system"

if Not objFSO.FolderExists(MY_FOLDER1) Then
End if

GrantPermissionToDirectory MY_FOLDER1

Function MakeDir (strPath)
Dim strParentPath, objFSO

strParentPath = objFSO.GetParentFolderName(strPath)

If Not objFSO.FolderExists(strParentPath) Then
MakeDir strParentPath
End if
If Not objFSO.FolderExists(strPath) Then
objFSO.CreateFolder strPath
End if
MakeDir = objFSO.FolderExists(strPath)
End Function

Function GrantPermissionToDirectory(directory)
Dim Result,strCommand,objShell
strCommand = "icacls " & Chr(34) & directory & Chr(34)& " /grant *S-1-5-32-544:(OI)(CI)F /grant *S-1-5-32-545:(OI)(CI)F"
Result = objShell.Run(strCommand, 0, True)
If (Result <> 0) Then
clsLogfile.WriteLine strLogfile, 8, "ERROR: Can't grant permissions to '" & directory & "' directory - Errorcode: " & Result
End If
End Function
Answered 05/07/2011 by: itolutions
Purple Belt

be carefull i am using icacls
Answered 05/07/2011 by: itolutions
Purple Belt