Push host file through batch script

Discussion in 'Microsoft Windows 2000 CMD Promt' started by fem, Apr 23, 2004.

  1. fem

    fem Guest

    Hi,

    I'm trying to push host file out to the clients pc using
    batch script. I have one global batch script and when i
    modify that script, i would like to send it out to the
    user system32\drivers\etc folder. Since the user don't
    have admin rights the host file is not copying over..would
    any one know how to do this without giving user admin
    rights.

    Thanks,
    Fem
     
    fem, Apr 23, 2004
    #1
    1. Advertisements

  2. fem

    Bill Stewart Guest

    fem <> wrote:

    > I'm trying to push host file out to the clients pc using batch script. I
    > have one global batch script and when i modify that script, i would like
    > to send it out to the user system32\drivers\etc folder. Since the user
    > don't have admin rights the host file is not copying over..would any one
    > know how to do this without giving user admin rights.


    Hi fem,

    Your users don't need admin rights; only you do. Just copy the file to:

    \\<computername>\ADMIN$\system32\drivers\etc

    Of course, replace <computername> as appropriate.

    HTH,

    Bill
     
    Bill Stewart, Apr 23, 2004
    #2
    1. Advertisements

  3. fem

    fem Guest

    Thanks,
    but is there any way we can send it all computers instead
    of typing in each computer name. Since we have over
    300pcs that needs to be updated.

    Thanks in advance
    >-----Original Message-----
    >fem <> wrote:
    >
    >> I'm trying to push host file out to the clients pc

    using batch script. I
    >> have one global batch script and when i modify that

    script, i would like
    >> to send it out to the user system32\drivers\etc

    folder. Since the user
    >> don't have admin rights the host file is not copying

    over..would any one
    >> know how to do this without giving user admin rights.

    >
    >Hi fem,
    >
    >Your users don't need admin rights; only you do. Just

    copy the file to:
    >
    >\\<computername>\ADMIN$\system32\drivers\etc
    >
    >Of course, replace <computername> as appropriate.
    >
    >HTH,
    >
    >Bill
    >
    >
    >.
    >
     
    fem, Apr 23, 2004
    #3
  4. fem

    wadester Guest

    In article <362a01c42959$a8b30830$>,
    wrote...
    > Thanks,
    > but is there any way we can send it all computers instead
    > of typing in each computer name. Since we have over
    > 300pcs that needs to be updated.


    This is what login scripts are generally used for. If you are not
    currently using them, this might be a good time to implement.

    Otherwise, if you just do a NET VIEW (or something similar) and push
    files to all those computers, you'll miss out on any computers that
    happened to be powered off or otherwise unreachable.

    ws

    --
    I saw this in a movie about a bus that had to SPEED around a city,
    keeping its SPEED over fifty, and if its SPEED dropped, it would
    explode. I think it was called, "The Bus That Couldn't Slow Down."
     
    wadester, Apr 23, 2004
    #4
  5. fem

    Bill Stewart Guest

    fem <> wrote:

    > but is there any way we can send it all computers instead of typing in
    > each computer name. Since we have over 300pcs that needs to be updated.


    Yes. The FOR command is your friend.

    First, put the computer names into a text file, one per line; you can use
    the NET VIEW command as a starting point; e.g.

    NET VIEW > LIST.TXT

    Edit the file LIST.TXT and remove the extra lines at the beginning and end
    of the file and save it.

    Next, use the FOR /F command to parse each line of the file:

    FOR /F %%c IN (LIST.TXT) DO @ECHO COPY <yourhostsfile>
    \\%%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD

    The above two lines are a single command; make sure to type it all one one
    line (with a space after your hosts file name).

    Last, open the DO_IT.CMD and make sure that it looks right, and that you
    are not performing the copy to any machines you did not intend to.

    If all is well, you can run the DO_IT.CMD script to make the change. Review
    it carefully before running it.

    One thing to note is that the above FOR command will not work properly if
    you have any computer names that contain a space.

    HTH,

    Bill
     
    Bill Stewart, Apr 23, 2004
    #5
  6. fem

    Bill Stewart Guest

    I wrote:

    > FOR /F %%c IN (LIST.TXT) DO @ECHO COPY <yourhostsfile>
    > \\%%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD


    Oops! The \\ is already there, so the line should actually be:

    FOR /F %%c in (LIST.TXT) DO @ECHO COPY <yourhostsfile>
    %%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD

    HTH,

    Bill
     
    Bill Stewart, Apr 23, 2004
    #6
  7. fem

    fem Guest

    would this still work if the computer don't have file or
    printer share enabled?

    thanks again.
    I'm using the login batch script...since the users don't
    have rights on their computer/domain...they can't copy the
    hosts file over to their system32/drivers/etc folder.


    >-----Original Message-----
    >fem <> wrote:
    >
    >> but is there any way we can send it all computers

    instead of typing in
    >> each computer name. Since we have over 300pcs that

    needs to be updated.
    >
    >Yes. The FOR command is your friend.
    >
    >First, put the computer names into a text file, one per

    line; you can use
    >the NET VIEW command as a starting point; e.g.
    >
    >NET VIEW > LIST.TXT
    >
    >Edit the file LIST.TXT and remove the extra lines at the

    beginning and end
    >of the file and save it.
    >
    >Next, use the FOR /F command to parse each line of the

    file:
    >
    >FOR /F %%c IN (LIST.TXT) DO @ECHO COPY <yourhostsfile>
    > \\%%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD
    >
    >The above two lines are a single command; make sure to

    type it all one one
    >line (with a space after your hosts file name).
    >
    >Last, open the DO_IT.CMD and make sure that it looks

    right, and that you
    >are not performing the copy to any machines you did not

    intend to.
    >
    >If all is well, you can run the DO_IT.CMD script to make

    the change. Review
    >it carefully before running it.
    >
    >One thing to note is that the above FOR command will not

    work properly if
    >you have any computer names that contain a space.
    >
    >HTH,
    >
    >Bill
    >
    >
    >.
    >
     
    fem, Apr 23, 2004
    #7
  8. "Bill Stewart" wrote:

    >I wrote:
    >
    >> FOR /F %%c IN (LIST.TXT) DO @ECHO COPY <yourhostsfile>
    >> \\%%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD

    >
    >Oops! The \\ is already there, so the line should actually be:


    And you could filter on that:

    @echo off
    FOR /F "tokens=1" %%c in ('net view ^|find "\\"') DO (
    ECHO COPY <yourhostsfile> >%%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD
    )

    But this will also give only a snapshot of currently running pc's

    --
    Greetings
    Matthias________________________________________
    For help on nt commands enter in a cmd window:
    W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
     
    Matthias Tacke, Apr 23, 2004
    #8
  9. fem

    Bill Stewart Guest

    fem <> wrote:

    > would this still work if the computer don't have file or printer share
    > enabled?


    No, it won't.

    Bill
     
    Bill Stewart, Apr 23, 2004
    #9
  10. fem

    Bill Stewart Guest

    Matthias Tacke <> wrote:

    > And you could filter on that:
    >
    > @echo off
    > FOR /F "tokens=1" %%c in ('net view ^|find "\\"') DO (
    > ECHO COPY <yourhostsfile> >%%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD
    > )


    This is true, of course; but I wanted to explain step-by-step as the OP
    does not seem to have any scripting experience.

    Thanks,

    Bill
     
    Bill Stewart, Apr 23, 2004
    #10
  11. "Bill Stewart" wrote:

    >Matthias Tacke <> wrote:
    >
    >> And you could filter on that:
    >>
    >> @echo off
    >> FOR /F "tokens=1" %%c in ('net view ^|find "\\"') DO (
    >> ECHO COPY <yourhostsfile> >%%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD
    >> )

    >
    >This is true, of course; but I wanted to explain step-by-step as the OP
    >does not seem to have any scripting experience.
    >

    Of course no offense meant Bill, I know your expertise.
    My attenttion is more on the tv at the moment, watchung snooker
    world champ in Sheffield :)

    --
    Greetings
    Matthias________________________________________
    For help on nt commands enter in a cmd window:
    W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
     
    Matthias Tacke, Apr 23, 2004
    #11
  12. fem

    Bill Stewart Guest

    Matthias Tacke <> wrote:

    > Of course no offense meant Bill, I know your expertise.


    None taken. :)

    Regards,

    Bill
     
    Bill Stewart, Apr 23, 2004
    #12
  13. fem

    Jens Hastrup Guest

    Hi Fem,

    Why not run your script as a machine startup script through Group Policy -
    it would solve your admin rights problem.

    Jens
    "fem" <> skrev i en meddelelse
    news:356301c4294c$d20f2e00$...
    > Hi,
    >
    > I'm trying to push host file out to the clients pc using
    > batch script. I have one global batch script and when i
    > modify that script, i would like to send it out to the
    > user system32\drivers\etc folder. Since the user don't
    > have admin rights the host file is not copying over..would
    > any one know how to do this without giving user admin
    > rights.
    >
    > Thanks,
    > Fem



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.667 / Virus Database: 429 - Release Date: 23-04-2004
     
    Jens Hastrup, Apr 24, 2004
    #13
  14. For NT-class machines (i.e. non Win9x), the computers must have the
    "Workstation" service running to be able to copy a file from a central UNC
    machine. Else, it must have the "Server" service running for a remote
    machine to push files to it via UNC.

    --
    //David
    IIS
    This posting is provided "AS IS" with no warranties, and confers no rights.
    //
    "fem" <> wrote in message
    news:375401c42962$f49c6300$...
    would this still work if the computer don't have file or
    printer share enabled?

    thanks again.
    I'm using the login batch script...since the users don't
    have rights on their computer/domain...they can't copy the
    hosts file over to their system32/drivers/etc folder.


    >-----Original Message-----
    >fem <> wrote:
    >
    >> but is there any way we can send it all computers

    instead of typing in
    >> each computer name. Since we have over 300pcs that

    needs to be updated.
    >
    >Yes. The FOR command is your friend.
    >
    >First, put the computer names into a text file, one per

    line; you can use
    >the NET VIEW command as a starting point; e.g.
    >
    >NET VIEW > LIST.TXT
    >
    >Edit the file LIST.TXT and remove the extra lines at the

    beginning and end
    >of the file and save it.
    >
    >Next, use the FOR /F command to parse each line of the

    file:
    >
    >FOR /F %%c IN (LIST.TXT) DO @ECHO COPY <yourhostsfile>
    > \\%%c\ADMIN$\system32\drivers\etc >> DO_IT.CMD
    >
    >The above two lines are a single command; make sure to

    type it all one one
    >line (with a space after your hosts file name).
    >
    >Last, open the DO_IT.CMD and make sure that it looks

    right, and that you
    >are not performing the copy to any machines you did not

    intend to.
    >
    >If all is well, you can run the DO_IT.CMD script to make

    the change. Review
    >it carefully before running it.
    >
    >One thing to note is that the above FOR command will not

    work properly if
    >you have any computer names that contain a space.
    >
    >HTH,
    >
    >Bill
    >
    >
    >.
    >
     
    David Wang [Msft], Apr 25, 2004
    #14
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ritchie

    Re: Hard challange: Create BKS file through Batch file

    Ritchie, Jul 25, 2003, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    0
    Views:
    823
    Ritchie
    Jul 25, 2003
  2. Beren

    Re: Hard challange: Create BKS file through Batch file

    Beren, Jul 25, 2003, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    0
    Views:
    2,463
    Beren
    Jul 25, 2003
  3. Don I

    Batch File as Login Script

    Don I, Feb 18, 2005, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    2
    Views:
    2,793
    Al Dunbar [MS-MVP]
    Feb 20, 2005
  4. Setting a batch script to read a text file

    , Apr 21, 2007, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    2
    Views:
    9,060
    Herb Martin
    Apr 21, 2007
  5. swathik

    Create .bks file using batch script

    swathik, Sep 21, 2011, in forum: Microsoft Windows 2000 CMD Promt
    Replies:
    0
    Views:
    1,473
    swathik
    Sep 21, 2011
Loading...

Share This Page