PC Review


Reply
Thread Tools Rate Thread

Push host file through batch script

 
 
fem
Guest
Posts: n/a
 
      23rd Apr 2004
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
 
Reply With Quote
 
 
 
 
Bill Stewart
Guest
Posts: n/a
 
      23rd Apr 2004
fem <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
 
fem
Guest
Posts: n/a
 
      23rd Apr 2004
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 <(E-Mail Removed)> 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
>
>
>.
>

 
Reply With Quote
 
wadester
Guest
Posts: n/a
 
      23rd Apr 2004
In article <362a01c42959$a8b30830$(E-Mail Removed)>,
(E-Mail Removed) 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."
 
Reply With Quote
 
Bill Stewart
Guest
Posts: n/a
 
      23rd Apr 2004
fem <(E-Mail Removed)> 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


 
Reply With Quote
 
Bill Stewart
Guest
Posts: n/a
 
      23rd Apr 2004
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


 
Reply With Quote
 
fem
Guest
Posts: n/a
 
      23rd Apr 2004
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 <(E-Mail Removed)> 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
>
>
>.
>

 
Reply With Quote
 
Matthias Tacke
Guest
Posts: n/a
 
      23rd Apr 2004
"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
 
Reply With Quote
 
Bill Stewart
Guest
Posts: n/a
 
      23rd Apr 2004
fem <(E-Mail Removed)> wrote:

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


No, it won't.

Bill


 
Reply With Quote
 
Bill Stewart
Guest
Posts: n/a
 
      23rd Apr 2004
Matthias Tacke <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A script/batch to kill a batch file from scheduled tasks? Bogdan Windows XP Configuration 1 31st Jul 2009 06:05 AM
'Status', toggle or push-push button Andrew Gabb Microsoft Access 1 26th May 2008 08:39 AM
Can do push left, need push right baker_tony@hotmail.com Windows XP MovieMaker 1 17th Jan 2006 05:21 PM
connecting to printer through batch file or script file =?Utf-8?B?c3JpZGhhcg==?= Windows XP Hardware 1 8th Feb 2005 07:49 PM
Windows Script host-Cannoot find script file =?Utf-8?B?U2FteWV1bmc=?= Windows XP General 6 26th Jan 2005 08:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:24 PM.