Write yourself a function and application instance, used to set the relevant permissions of the object, need friends can refer to the following
copy code code as follows:
Function generatesddl (AccountName, Accessflag, AccessType, AccessMask)
Dim Accounts, Objwmi, Objsid, Objtru, objACE
Const set_dacl_present = &h8004
Set objwmi = GetObject ("winmgmts:" & "{impersonationlevel=impersonate, (Security)}!." Rootcimv2 ")
Set Accounts = Objwmi.execquery ("select * from Win32_account WHERE name= '" & AccountName & "")
For the Accounts
Strsid = Account.sid
Next
Set Objsid = Objwmi.get ("Win32_SID. Sid= ' "& Strsid &" ")
Set Objtru = Objwmi.get ("Win32_Trustee"). SpawnInstance_ ()
Objtru.domain = Objsid.referenceddomainname
Objtru.name = Objsid.accountname
Objtru.sid = Objsid.binaryrepresentation
Objtru.sidlength = Objsid.sidlength
objtru.sidstring = Objsid.sid
Set objACE = Objwmi.get ("Win32_ACE"). SpawnInstance_ ()
objACE.Trustee = Objtru
objACE.AceType = AccessType
objACE.AccessMask = AccessMask
Objace.aceflags = Accessflag
Set GENERATESDDL = Objwmi.get ("Win32_securitydescriptor"). SpawnInstance_ ()
Generatesddl.owner = Objtru
Generatesddl.dacl = Array (objACE)
Generatesddl.controlflags = Set_dacl_present
End Function
Example:
Copy Code code as follows:
strpath = "D:1.txt"
Set objwmi = GetObject ("winmgmts:" & "{impersonationlevel=impersonate, (Security)}!." Rootcimv2 ")
Set objsec = Objwmi.get ("Win32_logicalfilesecuritysetting.path= '" & strpath & "")
Objsec.setsecuritydescriptor (GENERATESDDL ("Everyone", &h0, &h1, &h100e0))
Article Source: http://www.enun.net/?p=1255