Hi everyone,

I'm a bit new here, I read a lot of threads, I usually try to help myself with solved threads before posting questions (on other forums) but I could not find the solution for this yet

I have an Excel sheet with data of my PCs - hostnames, IP address and some more additional data. I would like to update the Windows hosts file with the data from the sheet by clicking a button in Excel. That is the plan, at least...

Well, I got stuck at the following things and I'm not sure how to continue:
  • How to set up the macro (there are more ways, I suppose, which would be the best one?)
    1. Always create new hosts file and replace old one every time + do Shell ("ipconfig /flushdns") + do Shell ("nbtstat -R")
    2. Find strings #EXCEL and #/EXCEL in the hosts file and replace only the text in between those 2 strings + do Shell ("ipconfig /flushdns") + do Shell ("nbtstat -R") (Note: I will edit the hosts files so they all have the #EXCEL and #/EXCEL strings!)
    3. ?
  • Will Excel have to be started with admin rights to be able to interact with the hosts file?

The second option would be much better for me as I have a few custom hosts specified on machines and I don't want to manually edit them every time the macro runs. The macro would be run on more different machines but with same Excel sheet - I will probably have to run the macro locally, I won't be able to do it over LAN as the file is in C:\Windows\System32\drivers\etc folder and needs admin rights to be changed. The number of PCs is currently 10 and the number will rise

I probably forgot something, I should be able to program the export part myself by using examples on the internet

If someone could help me, I'd appreciate any help

Best regards,
Dex