Office中国论坛/Access中国论坛

标题: 有办法用.bat或修改注册表的方法修改文件夹的安全权限吗? [打印本页]

作者: 雨农    时间: 2008-7-2 14:38
标题: 有办法用.bat或修改注册表的方法修改文件夹的安全权限吗?
我把程序打包了安装,安装在c:\program files\下,因为.mde文件里边有本身的数据表(用作临时表),也有链接的数据表
当sql操作本身的数据表时提示无权修改,我晕,原来是文件夹的安全权限不够,后来把power users,users(我公司用域的)的权限改成完全控制后就没问题了。
有没有一个办法做一个.bat文件自动把安装文件夹的power users,users的权限改成完全控制?
作者: liwen    时间: 2008-7-2 15:38
使用VBS脚本,应该可以的,参考下面的贴子


http://topic.csdn.net/t/20050713/17/4142376.html
作者: 雨农    时间: 2008-7-3 16:48
版主,
那个是文件夹共享使用权限哦,不是文件夹安全权限,因为安装在c:\program files下面的程序都不是everyone,而是分不同用户组来定义权限的!
作者: liwen    时间: 2008-7-4 10:13
我看这代码应该是可以设置文件夹的安全权限的,它设置的是具体的文件夹如'c:\program files',但我不知道那个设置的含义。
那段代码可存为.VBS文件由WSH执行,也可在VBA中运行,只需将输出语句改一下即可

Sub test()
'   Connect   to   WMI   and   get   the   file   security   object   for   the   testfolder   directory
  Set wmiFileSecSetting = GetObject("winmgmts:Win32_LogicalFileSecuritySetting.path='c:\program files'")
   
  '   Use   the   Win32_LogicalFileSecuritySetting   Caption   property   to   create   a   simple   header before
  '   dumping   the   discretionary   access   control   list   (DACL).
'  WScript.Echo wmiFileSecSetting.Caption & ":" & vbCrLf
  MsgBox wmiFileSecSetting.Caption & ":" & vbCrLf
   
  '   Obtain   existing   security   descriptor   for   folder
  RetVal = wmiFileSecSetting.GetSecurityDescriptor(wmiSecurityDescriptor)
  If Err <> 0 Then
'          WScript.Echo "GetSecurityDescriptor   failed" & vbCrLf & Err.Number & vbCrLf & Err.Description
'          WScript.Quit
          MsgBox "GetSecurityDescriptor   failed" & vbCrLf & Err.Number & vbCrLf & Err.Description
          Exit Sub
  Else
'          WScript.Echo "GetSecurityDescriptor   suceeded"
          MsgBox "GetSecurityDescriptor   suceeded"
  End If
   
  '   Retrieve   the   content   of   Win32_SecurityDescriptor   DACL   property.
  '   The   DACL   is   an   array   of   Win32_ACE   objects.
  DACL = wmiSecurityDescriptor.DACL
   
  '   Display   the   control   flags   in   the   descriptor.
MsgBox "Control   Flags:     " & wmiSecurityDescriptor.ControlFlags
' WScript.Echo "Control   Flags:     " & wmiSecurityDescriptor.ControlFlags
   
  '   Obtain   the   trustee   for   each   access   control   entry   (ACE)   and   change   the   permissions


  '   in   the   AccessMask   for   each   ACE   to   read,   write,   and   delete.
  For Each wmiAce In DACL
           
  '   Get   Win32_Trustee   object   from   ACE
                Set Trustee = wmiAce.Trustee
  '         wscript.echo   "Trustee   Domain:   "     &   Trustee.Domain
          MsgBox "Trustee   Name:   " & Trustee.Name
         MsgBox "Access   Mask:   " & wmiAce.AccessMask
'          WScript.Echo "Trustee   Name:   " & Trustee.Name
'          WScript.Echo "Access   Mask:   " & wmiAce.AccessMask
  '   Set   read   access   to   the   owner,   group,   and   DACL   of   the   security   descriptor (131072)
‘我没弄清这个131072代表的含义,但这个数=2^17
          wmiAce.AccessMask = 16384
         MsgBox "Access   Mask:   " & wmiAce.AccessMask
'          WScript.Echo "Access   Mask:   " & wmiAce.AccessMask
  Next
   
  '   Call   the   Win32_LogicalFileSecuritySetting.SetSecurityDescriptor   method
  '   to   write   the   new   security   descriptor.
  RetVal = wmiFileSecSetting.SetSecurityDescriptor(wmiSecurityDescriptor)
   
  MsgBox "ReturnValue   is:     " & RetVal
'  WScript.Echo "ReturnValue   is:     " & RetVal
End Sub
作者: 雨农    时间: 2008-7-8 11:06
谢谢,看看先
作者: xuwenning    时间: 2008-7-8 11:25
学习了[:33]
作者: twins    时间: 2009-3-21 22:33
有个命令行工具可以修改ntfs权限的。xcal什么的,一下子忘了。
作者: jxq998    时间: 2009-5-22 14:59
应该是没什么问题吧




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3