вам нужно только две команды
- используйте
net use
для подключения общего ресурса
- используйте
xcopy
для копирования файлов
пример скрипта:
net use z: \\some_host\$c secret_password /user:some_domain\some_user
md g:\xc
xcopy z:*.mp3 g:\xc\ /E /C /I /G /H /Z /B
xcopy z:*.wav g:\xc\ /E /C /I /G /H /Z /B
xcopy z:*.mp4 g:\xc\ /E /C /I /G /H /Z /B
где параметры net use
:
z: - some free drive letter
\\some_host\$c - default windows C:\ share on some_host in your network
/user: - user that have access to this share
secret_password - this user password
где параметры xcopy
:
z:*.mp3 Source and file mask
g:\xc\ Destination
/E Copies directories and subdirectories, including empty ones.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/Z Copies networked files in restartable mode.
/B Copies the Symbolic Link itself versus the target of the link.
вы можете выполнить обратное копирование на всех текущих компьютерах домена, используя psexec, если в качестве компьютера вы указали шаблон (\\*
)
psexec \\* -u some_domain\some_user -p secret_password -h -c script.cmd
где
-u Specifies optional user name for login to remote
computer.
-p Specifies optional password for user name. If you omit this
you will be prompted to enter a hidden password.
-h If the target system is Vista or higher, has the process
run with the account's elevated token, if available.
-c Copy the specified program to the remote system for
execution. If you omit this option the application
must be in the system path on the remote system.
пример script.cmd
:
net use z: \\your_host\some_share
xcopy c:*.mp3 z:\ /E /C /I /G /H /Z /B /R /Y
net use z: /delete
где вы должны использовать дополнительные параметры:
/R Overwrites read-only files.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.