New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

How to programmatically manipulate file permissions etc...

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to programmatically manipulate file permissions etc...

    Anyone know how to programmatically manipulate file permissions etc...

    I am trying to figure out how to strip all permissions from files as I move them from my old C drive to a backup location.

  • #2
    User permissions or attributes?

    If useers permissions, permissions on the original or the copies?
    Permissions are applied to the copied files based on the permissions of the directory they are being copied to.
    If attributes, Shell to a Cmdline and use "attrib".

    To alter user permissions on the original file is a lot more complex Here's some VB code which you may be able to adapt:


    • #3
      Check the PB Help file:
      SETATTR filespec$, attribute
      Sets the file system attribute(s) of a disk file or directory.



      • #4
        Thanks guys!

        I was talking about the permissions like Read, Write, Read&Write, List Folder Contents, Modify and Full Control. Also how to change the owner from Trusted Installer to something else.


        • #5
          Thanks for the link Stuart!


          • #6
            This looks difficult to convert to PB from VB, how to convert this method to PB?



            • #7
              Look in and


              • #8
                how about a batch file
                has to be run as the administrator to give all access to directory including delete it, i believe.
                this should give access to read and write to the drive directory and all files in the directory and sub directories inside it to all users.
                I never go back to removing rights. I guess you could delete the directory if needed to reset it.

                ECHO OFF
                IF EXIST "C:\%1" GOTO DOIT
                GOTO BAD
                icacls "c:\%1" /grant:r Users:(OI)(CI)F /T
                GOTO QUIT
                ECHO bad directory name
                ECHO %1

                commands to give total rw access and all other rights to directories and files under the root c: drive for the listed directories
                to give totall access to these directories

                c:\wsbat is the directory location where i keep all my batch processes

                run the below as an administrator
                call c:\wsbat\giverdrw inhouse
                call c:\wsbat\giverdrw other
                call c:\wsbat\giverdrw otherdll
                call c:\wsbat\giverdrw temp

                for what it is worth, i set all my other drives letters other than c: to be used by all users using the disk management tools in area. diskmgmt.msc
                Most of the time, I set the other than c: drives to users but you can set it to everyone and be done with it.
                p purvis


                • #9
                  You may have a look at Change file or folder ownership on NTFS drive


                  • #10
                    Paul Purvis already showcased the ICACLS tool. Another way to do it is with PowerShell: I recommend to become familiar with PS, as it will slowly take over the old CMD world. Bonus point: it's available for Linux, too. So your scripts can potentially run an various OSs.