Announcement

Collapse
No announcement yet.

Using batch file to apply security to directory

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using batch file to apply security to directory

    Is is possible to use a batch file with scripting to apply NT security to a directory after that security is changed?
    If so, what would the commands be?

  • #2
    Re: Using batch file to apply security to directory

    If you give us an example of what you are doing, maybe we can recommend a solution for this.

    As far as changing security from a batch file, you can use cacls to do this. An example might be:

    cacls \\server\share\directory /T /G / E "Domain admins":F

    You can type cacls at the command line to see the different switches and options.

    Comment


    • #3
      Re: Using batch file to apply security to directory

      An example would be the following:
      A directory currently has domain admins full control and a user with read write change permissions. We want to add a user to this directory. We add the user and would like to apply this user to NT permissions automatically, and it won't be the same user every time. Can we use cacls to dynamically apply the NT permissions?

      Comment


      • #4
        Re: Using batch file to apply security to directory

        Using the /E on the cacls command allows you to add the specified user without overwriting the existing ACL, so that will work for adding the additional user.

        As far as a different user each time, this will depend on how you are running the batch file. Basically what you can do is change your command in your batch file to:

        cacls \\server\share\directory /T/G/E %1:F

        Then when you run your batch file you put the user on the command line such as:

        modify.bat cmccullough

        When you run the batch file, it will substitute the %1 with the first parameter in the command, which in this case would be cmccullough. So the cacls command would be changed to:

        cacls \\server\share\directory /T/G/E cmccullough:F

        Comment


        • #5
          Re: Using batch file to apply security to directory

          Following your suggestion about the batch file and passing the parameters to it (%1). This is exactly how I am performing it but what I would like to know is if there a way I run this batch file in the 'post user' section and pass the username I just created to the bacthfile automotically.

          So I want to:

          1) Create a new user (I am using templates to do the share and home drive)
          2) Run my batch file for creating the users roaming profile directory and apply the necessary security to the folder.
          3) I want the batch file to run automatic 'post user', but I need to pass the userid (parameter) I just created to the batch file.

          Is this possible??

          Comment


          • #6
            Re: Using batch file to apply security to directory

            Hyena will pass parameters to your batch file in the same manner.

            The easiest way to see what each of these actually is, is to put this in your batch file:

            echo 1=%1
            echo 2=%2
            echo 3=%3
            echo 4=%4
            echo 5=%5
            echo 6=%6
            echo 7=%7
            pause

            Then add a test user, and you should see a DOS box popup and allow you to see what each variable is. Then just use the one you need in your batch file.

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎