Using Cacls in a vbscript - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Using Cacls in a vbscript

cookieheadcookiehead Posts: 7Member
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.

Option Explicit

Dim Fso
Set Fso = CreateObject("Scripting.FileSystemObject")

Dim TxtFile
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
'everyone:c
'%systemroot%system32cacls.exe e:projects empdocuments /t /e /g
'everyone:c
'%systemroot%system32cacls.exe e:projects empdrawings /t /e /g
'everyone:c

Const ForReading = 1
Dim Txt, Ts
Set Txt = Fso.GetFile(TxtFile)
Set TS = Txt.OpenAsTextStream(ForReading)

Dim ACLCommand
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

Comments

  • GameTroyGameTroy Posts: 214Member
    : 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.
    :
    : Option Explicit
    :
    : Dim Fso
    : Set Fso = CreateObject("Scripting.FileSystemObject")
    :
    : Dim TxtFile
    : 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
    : 'everyone:c
    : '%systemroot%system32cacls.exe e:projects empdocuments /t /e /g
    : 'everyone:c
    : '%systemroot%system32cacls.exe e:projects empdrawings /t /e /g
    : 'everyone:c
    :
    : Const ForReading = 1
    : Dim Txt, Ts
    : Set Txt = Fso.GetFile(TxtFile)
    : Set TS = Txt.OpenAsTextStream(ForReading)
    :
    : Dim ACLCommand
    : 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
    :
    :
    '--------------------------------
    what is cacls?
    just curious.



    Moses 1:39 - "For behold, this is my work and my glory-to bring to pass the immortality and eternal life of man.


    -Troy



  • cookieheadcookiehead Posts: 7Member
    Troy, Cacls allows permissions folder manipulation in a Windows Enviornment.




    : : 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.
    : :
    : : Option Explicit
    : :
    : : Dim Fso
    : : Set Fso = CreateObject("Scripting.FileSystemObject")
    : :
    : : Dim TxtFile
    : : 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
    : : 'everyone:c
    : : '%systemroot%system32cacls.exe e:projects empdocuments /t /e /g
    : : 'everyone:c
    : : '%systemroot%system32cacls.exe e:projects empdrawings /t /e /g
    : : 'everyone:c
    : :
    : : Const ForReading = 1
    : : Dim Txt, Ts
    : : Set Txt = Fso.GetFile(TxtFile)
    : : Set TS = Txt.OpenAsTextStream(ForReading)
    : :
    : : Dim ACLCommand
    : : 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
    : :
    : :
    : '--------------------------------
    : what is cacls?
    : just curious.
    :
    :
    :
    : Moses 1:39 - "For behold, this is my work and my glory-to bring to pass the immortality and eternal life of man.
    :
    :
    : -Troy
    :
    :
    :
    :

Sign In or Register to comment.