Reputation: 1422
I am trying to create a script on Windows which when run on an admin PC:
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.
Upvotes: 23
Views: 250422
Reputation: 31
Regarding step 2., check manual for psexec command (sysinternal tools)
Upvotes: 2
Reputation: 1693
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
Upvotes: 16
Reputation: 1220
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.
Upvotes: 25
Reputation: 10845
Why for
? What do you want to iterate? Try this.
call :cpy pc-name-1
call :cpy pc-name-2
...
:cpy
net use \\%1\{destfolder} {password} /user:{username}
copy {file} \\%1\{destfolder}
goto :EOF
Upvotes: 5