Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy files to network computers on windows command line

I am trying to create a script on Windows which when run on an admin PC:

  1. Copies a folder from the admin PC into a group of network PCs by specifying the ip address / range
  2. For each destination PC, Navigate into the folder and run another script file.

Using the method described by seanyboy here:

net use \\{dest-machine}\{destfolder} {password} /user:{username}
copy {file} \\{dest-machine}\{destfolder}

I'm not sure on how i can write a 'for' loop to go through each 'dest-machine' and perform step 2. Any ideas would be greatly appreciated.

like image 915
Jay Avatar asked Sep 21 '12 02:09

Jay


People also ask

How do I copy files over a network?

To share a file or folder over a network in File Explorer, do the following: Right-click (or long-press) a file, and then select Show more options > Give access to > Specific people. Select a user on the network to share the file with, or select Everyone to give all network users access to the file.


2 Answers

check Robocopy:

ROBOCOPY \\server-source\c$\VMExports\ C:\VMExports\ /E /COPY:DAT

make sure you check what robocopy parameter you want. this is just an example. type robocopy /? in a comandline/powershell on your windows system.

like image 90
Tilo Avatar answered Sep 19 '22 04:09

Tilo


Below command will work in command prompt:

copy c:\folder\file.ext \\dest-machine\destfolder /Z /Y

To Copy all files:

copy c:\folder\*.* \\dest-machine\destfolder /Z /Y
like image 39
Anvesh Yalamarthy Avatar answered Sep 21 '22 04:09

Anvesh Yalamarthy