⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sol17-2.vbs

📁 Apress - Managing Enterprise Systems With The Windows Script Host Source Code
💻 VBS
字号:
'grant the user Freds Read/Execute permissions on the report.doc file
Const RIGHT_GENERIC_READ = 1179785
Const RIGHT_GENERIC_EXECUTE = 1179808
Const ACETYPE_ACCESS_ALLOWED = 0 
Dim objDACL, objNewAce, objACE
Dim objSecurity, objSD
Set objSecurity = CreateObject("ADsSecurity") 'create security object
Set objSD = objSecurity.GetSecurityDescriptor("FILE://d:\data\report.doc")
Set objDACL = objSD.DiscretionaryAcl 'get the Discretionary ACL DACL
Set objNewAce = CreateObject("AccessControlEntry")

'Set the properties for the ACE. Set the trustee to be the Freds account,
objNewAce.Trustee = "Acme\FSmith"
'allow permissions to read and execute file
objNewAce.AccessMask = RIGHT_GENERIC_READ Or RIGHT_GENERIC_EXECUTE
'allow access to file
objNewAce.AceType = ACETYPE_ACCESS_ALLOWED

'add ACE to DACL
objDACL.AddAce objNewAce
'assign the DACL back to the security descriptor
objSD.DiscretionaryAcl = objDACL
'set the security descriptor for the file
objSecurity.SetSecurityDescriptor objSD

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -