批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[原创] VBScript 克隆源对象的ACL到目标

本帖最后由 lxzzr 于 2013-8-13 23:40 编辑

准确的应该是附加源对象的权限到目标。
  1. '==============================================================
  2. ' Copyright (c) enun-net. All rights reserved.
  3. ' ScriptName: CloneACL.vbs
  4. ' Creation Date: 8/5/2013
  5. ' Last Modified: 8/5/2013
  6. ' Author: lxzzr
  7. ' Homepage: www.enun.net
  8. ' E-mail: 0x22e09@sina.com
  9. ' Description: Clone object's ACL.
  10. '==============================================================
  11. If WScript.Arguments.Count < 2 Then
  12. WScript.Echo "Usage: CloneACL <sObjectPath(file or Folder)> <dObjectPath(file or Folder)>"
  13. WScript.Quit 1
  14. End If
  15. sObjectPath = WScript.Arguments( 0 )
  16. dObjectPath = WScript.Arguments( 1 )
  17. Set ObjWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate, (Security)}!\\.\root\cimv2")
  18. Set scr = ObjWMI.Get("Win32_LogicalFileSecuritySetting=""" & Replace( sObjectPath,"\","\\") & """" )
  19. sReturn = scr.GetSecurityDescriptor( objSD )
  20. If ( sReturn <> 0 ) Then
  21. WScript.Echo "Could not get security descriptor: " & sReturn
  22. wscript.Quit sReturn
  23. End If
  24. Set dst = ObjWMI.Get("Win32_LogicalFileSecuritySetting=""" & Replace( dObjectPath,"\","\\") & """" )
  25. dReturn = dst.SetSecurityDescriptor( objSD )
  26. If ( dReturn <> 0 ) Then
  27. WScript.Echo "Could not set security descriptor: " & dReturn
  28. wscript.Quit dReturn
  29. End If
复制代码
https://www.enun.net/?p=2308
1

评分人数

    • broly: 感谢分享技术 + 1

返回列表