标题: [原创] VBScript 克隆源对象的ACL到目标 [打印本页]
作者: lxzzr 时间: 2013-8-13 23:38 标题: VBScript 克隆源对象的ACL到目标
本帖最后由 lxzzr 于 2013-8-13 23:40 编辑
准确的应该是附加源对象的权限到目标。- '==============================================================
- ' Copyright (c) enun-net. All rights reserved.
- ' ScriptName: CloneACL.vbs
- ' Creation Date: 8/5/2013
- ' Last Modified: 8/5/2013
- ' Author: lxzzr
- ' Homepage: www.enun.net
- ' E-mail: 0x22e09@sina.com
- ' Description: Clone object's ACL.
- '==============================================================
-
- If WScript.Arguments.Count < 2 Then
- WScript.Echo "Usage: CloneACL <sObjectPath(file or Folder)> <dObjectPath(file or Folder)>"
- WScript.Quit 1
- End If
-
- sObjectPath = WScript.Arguments( 0 )
- dObjectPath = WScript.Arguments( 1 )
- Set ObjWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate, (Security)}!\\.\root\cimv2")
-
- Set scr = ObjWMI.Get("Win32_LogicalFileSecuritySetting=""" & Replace( sObjectPath,"\","\\") & """" )
- sReturn = scr.GetSecurityDescriptor( objSD )
- If ( sReturn <> 0 ) Then
- WScript.Echo "Could not get security descriptor: " & sReturn
- wscript.Quit sReturn
- End If
-
- Set dst = ObjWMI.Get("Win32_LogicalFileSecuritySetting=""" & Replace( dObjectPath,"\","\\") & """" )
- dReturn = dst.SetSecurityDescriptor( objSD )
- If ( dReturn <> 0 ) Then
- WScript.Echo "Could not set security descriptor: " & dReturn
- wscript.Quit dReturn
- End If
复制代码
https://www.enun.net/?p=2308
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |