Make sure that your hosts file is not marked as read-only. If it is, you will get this exception regardless of current user permissions.
Program runs as SYSTEM still not able to edit hosts file
-
13-04-2022 - |
Question
I'm trying to edit the hosts file while my program is started as "NT AUTHORITY\SYSTEM" with psexec, and I still get UnauthorizedAccessException
. I thought that SYSTEM should be able to edit hosts file that's why I'm started my program with psexec -i -d -s myapp.exe
.
So what should I do to be able to edit hosts file?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow