Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
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

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.