Howto make a batch that will read a .txt file as input

Discussion in 'Scripting' started by David Lewis, Oct 17, 2003.

  1. David Lewis

    David Lewis Guest

    I want to use a batch file to copy/install stuff to remote machines.
    I want to have a text file with a list of machines to process as input
    to the batch. When the batch file runs it processes every machine
    in the list.

    Or maybe how do I have a batch process every machine in the domain
    except servers? That is needed also, as I have two different kinds of
    updates to deploy. OS updates to all machines and Software updates to
    specific machines.

    Last how could I check for OS versions. I might need to process NT
    different then Win2000
     
    David Lewis, Oct 17, 2003
    #1
    1. Advertising

  2. Here's how we process similar batch files:

    we create 2 batch files: one calls the other

    in the 1st one, it contains the command variables you want executed.
    example: (filename is auto.bat)
    rcmd \\%1 net stop spooler

    in the 2nd file, it contains the list of servers\machines. example:
    (filename is serverlist.bat (or whatever name))
    call auto.bat server-name-here
    call auto.bat server-name-here

    The 2nd file is editable in an excel spreadsheet as needed and then
    copy\pasted into this txt file and renamed to bat (or just directly to the
    bat file.)

    Thanks-
    Richard




    "David Lewis" <*@*.*> wrote in message
    news:...
    > I want to use a batch file to copy/install stuff to remote machines.
    > I want to have a text file with a list of machines to process as input
    > to the batch. When the batch file runs it processes every machine
    > in the list.
    >
    > Or maybe how do I have a batch process every machine in the domain
    > except servers? That is needed also, as I have two different kinds of
    > updates to deploy. OS updates to all machines and Software updates to
    > specific machines.
    >
    > Last how could I check for OS versions. I might need to process NT
    > different then Win2000
     
    Richard Moreno, Oct 17, 2003
    #2
    1. Advertising

  3. David Lewis

    Mike Guest

    ::~~Script~~.
    :: @echo off
    ::----------------------- batch code -----------------------

    ::variables
    :: sets initial variables

    :mainloop
    :: Loops through a file for server names
    for /F %%I in (c:\temp\server.txt) do Call :begin %%I
    goto :EOF

    :begin
    set srv=%1
    :do the deed
    : copys a file to the C:\Temp directory on a distant machine
    xcopy c:\temp\myfile.exe \\%srv%\c$\temp
    :exit

    --


    -------------------------------------------------------------------------
    FIGHT BACK AGAINST SPAM!
    Download Spam Inspector, the Award Winning Anti-Spam Filter
    http://mail.giantcompany.com


    "Richard Moreno" <> wrote in message
    news:...
    > Here's how we process similar batch files:
    >
    > we create 2 batch files: one calls the other
    >
    > in the 1st one, it contains the command variables you want executed.
    > example: (filename is auto.bat)
    > rcmd \\%1 net stop spooler
    >
    > in the 2nd file, it contains the list of servers\machines. example:
    > (filename is serverlist.bat (or whatever name))
    > call auto.bat server-name-here
    > call auto.bat server-name-here
    >
    > The 2nd file is editable in an excel spreadsheet as needed and then
    > copy\pasted into this txt file and renamed to bat (or just directly to the
    > bat file.)
    >
    > Thanks-
    > Richard
    >
    >
    >
    >
    > "David Lewis" <*@*.*> wrote in message
    > news:...
    > > I want to use a batch file to copy/install stuff to remote machines.
    > > I want to have a text file with a list of machines to process as input
    > > to the batch. When the batch file runs it processes every machine
    > > in the list.
    > >
    > > Or maybe how do I have a batch process every machine in the domain
    > > except servers? That is needed also, as I have two different kinds of
    > > updates to deploy. OS updates to all machines and Software updates to
    > > specific machines.
    > >
    > > Last how could I check for OS versions. I might need to process NT
    > > different then Win2000

    >
    >
     
    Mike, Oct 20, 2003
    #3
  4. David Lewis

    David Lewis Guest

    thankx

    "Mike" <>
    |>
    |>::~~Script~~.
    |>:: @echo off
    |>::----------------------- batch code -----------------------
    |>
    |>::variables
    |>:: sets initial variables
    |>
    |>:mainloop
    |>:: Loops through a file for server names
    |>for /F %%I in (c:\temp\server.txt) do Call :begin %%I
    |>goto :EOF
    |>
    |>:begin
    |>set srv=%1
    |>:do the deed
    |>: copys a file to the C:\Temp directory on a distant machine
    |>xcopy c:\temp\myfile.exe \\%srv%\c$\temp
    |>:exit
     
    David Lewis, Nov 4, 2003
    #4
    1. Advertising

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. Omer

    HOWTO: Read USB keyboard input from boot driver

    Omer, May 8, 2005, in forum: Windows Vista Drivers
    Replies:
    1
    Views:
    332
    Doron Holan [MS]
    May 8, 2005
  2. PowerAll
    Replies:
    1
    Views:
    386
    Travis Hobrla [MS]
    Jan 23, 2006
  3. officer07
    Replies:
    3
    Views:
    506
    Mervyn Zhang [MSFT]
    Mar 4, 2009
  4. Drew

    DSMOD - Read from TXT or CSV file

    Drew, Jul 13, 2005, in forum: Active Directory
    Replies:
    3
    Views:
    1,614
    Al Mulnick
    Jul 13, 2005
  5. Breck
    Replies:
    2
    Views:
    718
    Breck
    Nov 2, 2004
Loading...

Share This Page