I often utilize Windows Performance Counters to log Windows performance metrics.
By default, these counters log to C:\PerfLogs as the SYSTEM user.
This results in the log files only being accessible by the SYSTEM account or Administrators group.
Here are commands to take ownership of those folders:
takeown /F "C:\PerfLogs" /R /D Y
- /F specifies the folder.
- /R makes it recursive.
-
/D Y assumes “Yes” for any prompt.
icacls “C:\PerfLogs” /grant YourUserName:F /T`
- /grant gives permissions.
- F = Full control.
- /T applies to all subfolders and files.
You can verify the permissions using this command:
icacls "C:\PerfLogs"`
You should see your user listed with (F).
Alternative approach
Changing ownership from SYSTEM to your user may affect system monitoring logs.
If you want to keep SYSTEM as owner but still have access, you can add your
user to ACL without changing ownership:
icacls "C:\PerfLogs" /grant YourUserName:F /T
(Skip takeown in that case.)