I have created a script to revoke permissions to certain folders in c Drive . but the problem is the script have revoked rights of admin too and now whenener i try to access the folders even with admin account it doesnt give permissions. how to i set permissions to everyone again i wrote following script to give permissions to everyone but it doesnt seem to work.
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell= CreateObject("WScript.Shell")
Set objFolder = objFSO.GetFolder("D:\")
totalCount = objFolder.SubFolders.Count
wscript.echo totalCount
strHomeFolder= "D:\Data"
wscript.echo strHomeFolder
For Each folder in objFolder.SubFolders
wscript.echo folder.name
If InStr(folder.name, "Data") then
'intRunError= objShell.Run("icacls D:\Data /grant everyone:F")
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls "_& myFolder & " /t /c /p everyone:F administrator:F ", 2, "True")
End If
myFolder = "D:\" & folder.name
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls "_& myFolder & " /t /c /p everyone:F administrator:F ", 2, "True")
Next
'==========================================================================
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell= CreateObject("WScript.Shell")
Set objFolder = objFSO.GetFolder("C:\")
For Each folder in objFolder.SubFolders
wscript.echo folder.name
myFolder = "C:\" & folder.name
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls "_& myFolder & " /t /c /p everyone:F administrator:F ", 2, "True")
Next