+ Reply to Thread
Results 1 to 3 of 3

Editing hosts file from within Excel?

  1. #1
    Registered User
    Join Date
    11-26-2012
    Location
    Horjul, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Editing hosts file from within Excel?

    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

  2. #2
    Registered User
    Join Date
    11-26-2012
    Location
    Horjul, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Editing hosts file from within Excel?

    Bump

    Actually, this could refer to exporting to any file in general, not just hosts

  3. #3
    Registered User
    Join Date
    11-26-2012
    Location
    Horjul, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Editing hosts file from within Excel?

    Bump

    I guess a moderator can lock this, as I couldn't do it myself and it seems nobody can help me so the project is put away for... A while

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1