Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Using Cacls in a vbscript
Hi Everyone. I'm trying to set permissions on a set of folders using cacls. Does anyone know how to do this via a vbscript? Below is part of the code (if it helps). Your help would be greatly appreciated. Thanks.
Set Fso = CreateObject("Scripting.FileSystemObject")
Set TxtFile = Fso.GetFile("E:projectsTemppermissions.txt") 'Gets
'command lines to execute permission
'permission.txt contains following lines:
'%systemroot%system32cacls.exe e:projects empanalysis /t /e /g
'%systemroot%system32cacls.exe e:projects empdocuments /t /e /g
'%systemroot%system32cacls.exe e:projects empdrawings /t /e /g
Const ForReading = 1
Dim Txt, Ts
Set Txt = Fso.GetFile(TxtFile)
Set TS = Txt.OpenAsTextStream(ForReading)
ACLCommand = "cmd /c echo y| cacls"
ACLCommand = ACLCommand & TxtFile
Dim WshShell, Calcls
Set WshShell = CreateObject("WScript.Shell")
Calcls = WshShell.Run(ACLCommand, 0, True)
Set Fso = Nothing
Set WshShell = Nothing
0 · ·