2

need to push(deploy) few batch files to the machines on a network. All nodes are running Windows. The batch files contain some commands to initialize an env on each node.

what ways can this be accomplished? any tools readily available? thanks in adv.

JMS77
  • 1,275
  • 5
  • 27
  • 45
  • So you want to just copy the files to the computers? What's wrong with a quick batch/PS file to copy them? – Chris S Mar 16 '11 at 12:48
  • just to copy the files to multiple nodes on network and launch the batch files automatically – JMS77 Mar 16 '11 at 14:45

1 Answers1

3
  1. Create list of computers in a file (not exactly necessary, but usually the easiest), named computer.list (or whatever):

    wsn101
    wsn102
    wsn103
    
  2. Run batch file:

    for %%i in (computer.list) do copy file_to_push.ext \\%%i\c$
    for %%i in (computer.list) do psexec \\%%i C:\file_to_push.ext
    

    (Fixed this part, cp isn't right, should be copy)
    Link to download psexec if you don't have it already.

    Same thing in PS:

    foreach ($wsn in Get-Content Computer.List)
    {
        cp file_to_push.ext \\$wsn\c$
        psexec \\$wsn C:\file_to_push.ext
    }
    
Doug Luxem
  • 9,612
  • 7
  • 50
  • 80
Chris S
  • 77,945
  • 11
  • 124
  • 216
  • should these hostnames resolve to IPs? – JMS77 Mar 16 '11 at 17:23
  • @John, yes the names must resolve via NetBIOS or DNS; unless you're using NetBEUI. – Chris S Mar 16 '11 at 19:27
  • the above code is not working "syntax error in for loop"...I am not good in MS DOS batch...could you help pls? any equivalent in powershell? – JMS77 Mar 17 '11 at 14:19
  • @John - I updated the batch script with the correct %%i syntax. The %i would only work when typed from a command line. – Doug Luxem Mar 17 '11 at 17:33
  • @Doug, thank you, been too long since I used batch files apparently. – Chris S Mar 17 '11 at 17:42
  • 1
    FYI I had to put FOR /F into my script otherwise it told me the text file (list file) was "unexpected at this time" –  Oct 14 '13 at 04:48