wsl2_host_ip icon indicating copy to clipboard operation
wsl2_host_ip copied to clipboard

Access denied when updating hosts file.

Open dingo-d opened this issue 4 years ago • 2 comments
trafficstars

I've followed the instructions on setting up a scheduled task for creating the hosts file, I've put the program in the Program Files folder, created a scheduled task and set the elevated privileges. I've also installed .NetCore (had an error with that but then I've installed it).

I checked my C:\Windows\System32\drivers\etc folder, and saw no wsl2.host file created. So when checking my Event Viewer I found out one error with details:

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name=".NET Runtime" /> 
  <EventID Qualifiers="0">1000</EventID> 
  <Version>0</Version> 
  <Level>2</Level> 
  <Task>0</Task> 
  <Opcode>0</Opcode> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2021-07-02T09:49:20.3831874Z" /> 
  <EventRecordID>8541</EventRecordID> 
  <Correlation /> 
  <Execution ProcessID="0" ThreadID="0" /> 
  <Channel>Application</Channel> 
  <Computer>DESKTOP-JG3FGC7</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>Category: wslw_host_ip.Program EventId: 0 Access denied when updating hosts file.</Data> 
  </EventData>
  </Event>

Any idea what am I missing?

dingo-d avatar Jul 02 '21 09:07 dingo-d

Looking at my own settings here, the task runs only when the user is logged on, and runs with the highest privileges. Also, the current user that runs this is an administrator. So I'd suggest to check that these 3 conditions are met on your environment.

silverfoxy avatar Jul 02 '21 15:07 silverfoxy

Will do. I tried resetting the computer. The only user on the computer has admin privileges so that should be ok, but I'll take another look. 👍🏼

dingo-d avatar Jul 03 '21 10:07 dingo-d