如何添加Everyone用户,对该文件夹完全访问?

解决方案 »

  1.   

    哈哈,我搜过不过源码是C++的调用的API函数具体位置忘了现在我用这种方法调用CACLS.EXE程序,代码如下:
     Public Function DelFolderUser(ByVal path As String, ByVal UserName As String)
            If path.EndsWith("\") Then path = path.Substring(0, path.Length - 1)
            Dim CmdTxt As String
            CmdTxt = syspath & "Cacls.exe " & path & " /c /e /t /r " & UserName
            Shell(CmdTxt, vbHide)
            Return True
        End Function
        Public Function SetFolderUser(ByVal PathName As String, ByVal UserFlag As String, ByVal replace As Boolean) As Boolean
            'Set Change Permissions for the developer using CACLS.exe
            If PathName.EndsWith("\") And PathName.Length > 3 Then PathName = PathName.Substring(0, PathName.Length - 1).Trim
            ' PathName = PathName & "\"
            Dim strACLCommand As String, objRTC
            strACLCommand = " /c echo y|" & syspath & "Cacls.exe "
            strACLCommand = strACLCommand & PathName
            If replace Then
                strACLCommand = strACLCommand & " /c /t /g " & UserFlag
            Else
                strACLCommand = strACLCommand & " /c /e /t /g " & UserFlag
            End If
            Dim objWSH
            'Set objWSH = Server.CreateObject("WScript.Shell")
            'objRTC = objWSH.Run(strACLCommand, 0, True)
            'MsgBox(strACLCommand)
            Dim INF As ProcessStartInfo = New ProcessStartInfo
            INF.FileName = syspath & "cmd.exe "
            INF.Arguments = strACLCommand
            INF.WindowStyle = ProcessWindowStyle.Hidden
            Dim bb As System.Diagnostics.Process = System.Diagnostics.Process.Start(INF)
            bb.WaitForExit()
            bb.Close()
            ' Shell(strACLCommand, vbHide)
            'Set objWSH = Nothing
            Return True
        End Function