How to grant permission to users for a directory or file using command line in Windows?

Windows based issues resolved
Post Reply
RescuePC
Posts: 115
Joined: Wed Apr 04, 2012 8:48 pm

How to grant permission to users for a directory or file using command line in Windows?

Post by RescuePC »

How to grant permission to users for a directory or file using command line in Windows?

takeown /f <directory name> /r /d y

icacls <directory name>/q /c /t /grant <Users>:F

example to allow deletion of pagefile.sys if you pull the hard drive from a broken pc and attach to another computer

open CMD as administrator
takeown /f pagefile.sys
icacls pagefile.sys /grant administrators:F

Post Reply