The following bat file is being used to fix permissions for Users in our organization. Everything works perfectly until we try to set the owner back to the user.
takeown /F F:\Users\First.Last /R
icacls "F:\Users\First.Last" /grant:r system:(oi)(ci)f /t /c /Q
icacls "F:\Users\First.Last" /grant:r "Group admins":(oi)(ci)f /t /c /Q
icacls "F:\Users\First.Last" /grant:r "Domain admins":(oi)(ci)f /t /c /Q
icacls "F:\Users\First.Last" /grant:r "CREATOR OWNER":(OI)(CI)F /T /C /Q
icacls "F:\Users\First.Last" /grant:r First.Last:(oi)(ci)f /t /c /Q
icacls "F:\Users\First.Last" /remove:g "everyone" /T /C /Q
icacls "F:\Users\First.Last" /remove:g "administrators" /T /C /Q
icacls "F:\Users\First.Last" /remove Everyone /T /C /Q
icacls "F:\Users\First.Last" /setowner First.Last /c /t /Q
Here is the line that doesn't work in a bat file. It works perfectly fine when typing it into a Command Prompt:
icacls "F:\Users\First.Last" /setowner First.Last /c /t /Q
doesn't work in my bat file.
Is there another way to remove myself?
I applied fix Fix201044 from Microsoft's website and same result.
I am comfortable with using VBScript, PowerShell, Bat.
I am not comfortable with having to install 3rd party software that requires reboot or beta software.
This should set the Ownership for you using Powershell. I'm assuming this is in a domain environment