Is this the correct way to take ownership and reset folder and file permissions to default values?

Discussion in 'Scripting' started by anansay, Nov 18, 2020.

  1. anansay

    anansay MDL Junior Member

    Jul 13, 2020
    I have read What is Takeown and How to Use it to take Ownership of Files and Folders

    According to it, to take ownership of a folder and its sub-folders, I first need to cd to the relevant directory and type the following in an elevated command prompt:

    takeown /f "<foldername>" /r /d y
    However, the above action will not allow me to make changes to the files in the folder and its sub-folders, is that right?

    I have to take the following step in order to edit any of the files:

    icacls "<foldername>" /grant %username%:F /T
    Once the above action is taken, I will then be able to edit files in the relevant directory, correct?

    After I have made the necessary changes, in order to reset the relevant folder and its sub-directories to their original default permissions, I will have to:

    icacls * /t /q /c /reset
    Is the above the correct command?