开发者

Assign rights to folder VBA

I use the below code to assign rights to a folder. This works fine when I create a folder on say "C:/Test" and run the code. It works fine without any issues, but once I try the same with the folder "C:/Documents and Settings", I get an error.

Here is the code; it's VBA code done in a Word document.

Dim intRunError, objShell, objFSO,strHomeFolder         
strHomeFolder = "C:/Documents and Settings"

Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderE开发者_JS百科xists(strHomeFolder) Then
    intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls " _
        & strHomeFolder & " /e /c /g everyone:F ", 2, True)
End If
MsgBox intRunError


Perhaps:

"%COMSPEC% /c Echo Y| cacls """ & strHomeFolder & """ /e /c /g everyone:F "
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜