VBScript to Grant Permission
Here is a VBScript, which can be used to grant permissions on folder/file NTFS formatted drive. Just modify/tweak the script as per the requirements and follow various options available with CACLS.
This VBScript can be called and executed through Custom Action in application.
'--------------------Begin -----------
'This script will assign Modify/C-Change (write) Permission To Power User on "C:\MyFolder" using cacls on NTFS formatted drive
Dim oShell, FoldPerm, Calcds, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
sSysDir = oFSO.GetSpecialFolder(1).Path
If Right(sSysDir,1) <> "\" Then sSysDir = sSysDir & "\"
Calcds = sSysDir & "cacls.exe"
'Chang The folder Name, User and Access rights in the following line of code
FoldPerm = """" & Calcds &"""" & """C:\MyFolder""" & " /E /T /C /G " & """Power Users""" & ":C"
oShell.Run FoldPerm, 1 ,True
'----------------End of Script---------
As you can notice I have used CACLS to grant permissions in my script, you can use all the optins available CACLS.
Following is the Syntax and Various Option for using Cacls.
CACLS.exe filename [/T] [/E] [/C] [/G user:perm] [/R user [...]] [/P user:perm [...]] [/D user [...]]
| filename | Displays ACLs. |
| /T | Changes ACLs of specified files in the current directory and all subdirectories. |
| /E | Edit ACL instead of replacing it. |
| /C | Continue on access denied errors. |
| /G user:perm | Grant specified user access rights. Perm can be: R Read W Write C Change (write) F Full control |
| /R user | Revoke specified user's access rights (only valid with /E). |
| /P user:perm | Replace specified user's access rights. Perm can be: N None R Read W Write C Change (write) F Full control |
| /D user | Deny specified user access. |
Wildcards can be used to specify more that one file in a command.
You can specify more than one user in a command.
Abbreviations:
- CI - Container Inherit.
The ACE will be inherited by directories.
- OI - Object Inherit.
The ACE will be inherited by files.
- IO - Inherit Only.
The ACE does not apply to the current file/directory.
Thanks,
Sid
| License: | AJSL By clicking the download link below, you agree to the terms and conditions in the Altiris Juice Software License |
| Support: | User-contributed tools on the Juice are not supported by Altiris Technical Support. If you have questions about a tool, please communicate directly with the author by visiting their profile page and clicking the 'contact' tab. |
