Help with Batch File RRS feed

  • Question

  • I created a batch file to update a host on a list of servers. I'd like a little assistance in a way to then make another text file with the server name that got updated successfully. Here's what I have. It's pretty simple. Just looking for something to track success...

    ::@echo off
    set CompList=CompList.txt

    setlocal enabledelayedexpansion

    for /f "usebackq tokens=*" %%A in ("%CompList%") do (
    type hosts>>\\%%A\c$\windows\system32\drivers\etc\hosts

    • Moved by Bill_Stewart Wednesday, December 12, 2018 5:06 PM User should not be doing this
    Tuesday, August 14, 2018 7:37 PM

All replies

  • What do you mean by "track success"?

    What is "type hosts" supposed to do?  Is there a file in the current folder called "hosts"


    • Edited by jrv Tuesday, August 14, 2018 7:50 PM
    Tuesday, August 14, 2018 7:48 PM
  • Forget about batch files.  They are most obsolete and much harder to manage for non-techs.

    $hosts = Get-Content hosts
    Get-Content hostlist.txt |
            $hosts >> "\\$_\c$\windows\system32\drivers\etc\hosts"

    You should be using DNS for this.


    • Edited by jrv Tuesday, August 14, 2018 7:54 PM
    Tuesday, August 14, 2018 7:54 PM