我需要对本地磁盘上的所有文件夹、子文件夹和文件设置“读取”权限,但文件夹“$Recycle.Bin”除外。如何做到这一点?现在权限分布在所有但如何消除其中一个文件夹?
这是我尝试过的:
Function SetSystemDriveRightsVBS( strUPN, strRights )
On Error Resume Next
Set objEnvLocal = WshShell.Environment("Process")
Set FSLocal = CreateObject("Scripting.FileSystemObject")
systemRootFolder = objEnvLocal("SystemRoot")
systemDriveFolder = objEnvLocal("SystemDrive") & "\.."
Set rootFolder = FSLocal.GetFolder(systemRootFolder)
Call Information("Setting Rights on: " & systemDriveFolder, 0)
stdComspec = "cacls """ ' переменная env C:\Windows\System32\cmd.exe
stdRights = """ /T /E /C /G " & strUPN & ":" & strRights
' Setting Permissions on SystemDrive, SystemRoot, SystemRoot\system32 folders and there contents, if Administrator has a permission
Call RunEnc( stdComspec & systemDriveFolder & stdRights, consoleCharset)
Call RunEnc( stdComspec & systemRootFolder & stdRights, consoleCharset)
Call RunEnc( stdComspec & systemRootFolder &"\System32" & stdRights, consoleCharset)
Call RunEnc( stdComspec & systemRootFolder &"\SysWOW64" & stdRights, consoleCharset)
stdRights = """ /T /E /C /G " & strUPN & ":" & strRights
' A very very long recursive filesystem permission set
'Call SetRightsOnFolderContent(systemDriveFolder,stdComspec,stdRights)
' Обработка ошибок скрипта
If Err <> 0 Then
Call GlobalInformation("Error setting rights on DiskDrive:" & Err.Number & " -- " & Err.Description)
Err.Clear
End If
End Function