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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top