Editing Hosts File

  • Thread starter Thread starter Deadlyshadow
  • Start date Start date
or he can just type a runonce command to post setup.. to move a hosts file
 
While you can add the file from the Post-Setup page, I find the older method of including files easier if you need to update them. This way is faster since it doesn't require mounting the image every time you need to make changes.

1. Create a new folder, under your extracted ISO's directory.
Code:
\sources\$OEM$\$$\System32\drivers\etc

$$\System32\drivers\etc -> C:\Windows\System32\drivers\etc

2. Copy your HOSTS file into this folder. Apply changes and create a new ISO. The file will be deployed for any image you install.
 
Last edited:
While you can add the file from the Post-Setup page, I find the older method of including files easier if you need to update them. This way is easier since it doesn't require mounting the image every time you need to make one change.

1. Create a new folder, under your extracted ISO's directory.
Code:
\sources\$$\System32\drivers\etc

$$\System32\drivers\etc -> C:\Windows\System32\drivers\etc

2. Copy your HOSTS file into this folder. Apply changes and create a new ISO. The file will be deployed for any image you install.
Just to be sure, I need to create a folder tree (System32\drivers\etc) inside the "$$" folder, then place the hosts file in the "etc" folder....correct ?
 
Sorry, I posted the wrong path originally. \sources\$OEM$\$$\System32\drivers\etc

Yes. Anything under the $OEM$ folder hierarchy will be copied to the target system, mirroring the folder paths. $$ is a shortcut for C:\Windows.
 
Sorry, I posted the wrong path originally. \sources\$OEM$\$$\System32\drivers\etc

Yes. Anything under the $OEM$ folder hierarchy will be copied to the target system, mirroring the folder paths. $$ is a shortcut for C:\Windows.
Cool....Thanks

one last question...if the edited hosts file interfere with the windows setup process, wouldn't moving the file using post setup command method be more effective ? I want to edit the hosts file to prevent connection to known Microsoft trackers...the list is from this page (https://github.com/hagezi/dns-blocklists#native)
 
$OEM$ files are copied by WinPE Setup before it exits. Post-Setup commands executed after OOBE. The $OEM$ method would overwrite the default HOSTS file much earlier in the installation process.

Most of the time I find these privacy lists overblown, unless you're using O365 products. Because proper blocking requires a DNS-based ruleset and not compiled lists of random endpoints. But hey... it's not like I worked for one of these exact companies.
 
The $OEM$ method would overwrite the default HOSTS file much earlier in the installation process.
this is why I thought it would interfere with windows setup, so I appreciate if you teach me how to move the file post setup if that's not a bother
 
I reviewed that list, it won't interfere with proper Windows installation. If you're not using a MS Account logon, then all install requires is access to Windows Update servers.
 
I reviewed that list, it won't interfere with proper Windows installation. If you're not using a MS Account logon, then all install requires is access to Windows Update servers.
You've been much help, and not just this time........Thank You !
 
One you prepare the new hosts file, you can just drop it to the Post-setup page, tool will now set all automatically.
Confirm the file destination on the right, and it should be of 'Before logon' in Image type.
Will need to update the docs soon.
 
Last edited:
One you prepare the new hosts file, you can just drop it to the Post-setup page, tool will now set all automatically.
Confirm the file destination on the right, and it should be of "Before logon" type.
Will need to update the docs soon.
When I tried to directly replace the file when mounted using explore mount directory, it strangely worked...why not use this method directly?
 
This works, but it's time consuming because it only applies to one mounted image at a time.

Which is fine if you only have one image per ISO. If you have a multi-edition ISO, then this process has to be repeated for each separate image since the copied file isn't shared across all images. Moving the same file to the ISO level makes it less work to update.
 
When I tried to directly replace the file when mounted using explore mount directory, it strangely worked...why not use this method directly?
That's what the post-setup does, with the ease of having it in the preset for the next time, it will pull the hosts file where you keep it when the preset was saved.
 
Back
Top