Using cacls
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.
Thanks,
Usha
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.
Thanks,
Usha
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
itolutions
13 years ago
Try this
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
MY_FOLDER1 = "c:\system"
if Not objFSO.FolderExists(MY_FOLDER1) Then
MakeDir(MY_FOLDER1)
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
Quit(Result)
End If
End Function
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.