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

📄 setacl.wsf

📁 Apress - Managing Enterprise Systems With The Windows Script Host Source Code
💻 WSF
字号:
<?xml version="1.0"?>
<job>
<!--comment
Script:setacl.wsf
example on how to grant network share permissions 
-->
 <script language="VBScript" src="wmiinc.vbs">
 <![CDATA[
 Option Explicit
Const CHANGE = 1245631   
Const ACCESS_DENIED = 0 
Dim objShare, objDescriptor, objACE, retval, aDACL
 Dim objTrustee, objService
'get a reference to WMI service on the remote machine Odin
 Set objService = GetObject( _
               "winmgmts:{impersonationLevel=impersonate}!\\Odin") 
'get a reference to the data share on the remote machine Odin
 Set objShare = _
     objService.Get("Win32_LogicalShareSecuritySetting.Name='data'")

 'get the security descriptor and DACL
 retval = objShare.GetSecurityDescriptor(objDescriptor)
aDACL = objDescriptor.DACL
'create a new instance of an ACE and Trustee object
 Set objACE = objService.Get("Win32_ACE")
 Set objTrustee = objService.Get("Win32_Trustee") 

 'set trustee information    
 objTrustee.Name = "Acme\Freds"
 'assign the binary SID value for user account Freds
 objTrustee.SID = GetBinarySID("Freds")

 objACE.AccessMask = CHANGE
 objACE.AceType = ACCESS_DENIED
 objACE.Trustee = objTrustee

 'resize DACL array and assign to security descriptor    
 ReDim Preserve aDACL(UBound(aDACL) + 1)
 Set aDACL(UBound(aDACL)) = objACE
objDescriptor.dacl = aDACL
'set the security descriptor
 retval = objShare.SetSecurityDescriptor(objDescriptor)
]]>
 </script>
</job>

⌨️ 快捷键说明

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