[英]How to make array list in my case using Batch File Script?
I want to copy files from one folder to multiple pc in the local network.我想将文件从一个文件夹复制到本地网络中的多台电脑。
I want to add IP address in array list like below我想在数组列表中添加 IP 地址,如下所示
set list=\\192.168.55.102
set list=%list%;\\192.168.55.103
set list=%list%;\\192.168.55.104
set list=%list%;\\192.168.55.105
set list=%list%;\\192.168.55.106
then, I will copy file to above IP's by following code.然后,我将通过以下代码将文件复制到上述 IP。 But the following code will do for 1 ip.
但以下代码适用于 1 ip。 It's working and copied the file to destination location
它正在工作并将文件复制到目标位置
net use "\\192.168.55.102\c$\foldername" /user:%username% %password%
:copy
copy "C:\Desktop\Update" "\\192.168.55.102\c$\foldername"
IF ERRORLEVEL 0 goto disconnect
goto end
:disconnect
net use "\\192.168.55.102\c$\foldername" /delete
goto end
:end
I tried like below, but it doesn't work我尝试如下,但它不起作用
@echo off
for %a% in (%list%) do (
net use %a%\foldername /user:%username% %password%
:copy
copy "C:\Desktop\Update" %a%\foldername
IF ERRORLEVEL 0 goto disconnect
goto end
:disconnect
net use %a%\foldername /delete
goto end
:end
)
Create a variable (not array) and add the IP's separated by space, comma or semicolon.创建一个变量(不是数组)并添加以空格、逗号或分号分隔的 IP。 Then connect to
IPC$
to allow authentication, copy the file(s) and then remove the IPC$
share:然后连接到
IPC$
以允许身份验证,复制文件,然后删除IPC$
共享:
@echo off
set "list=192.168.55.102 192.168.55.103 192.168.55.104 192.168.55.105 192.168.55.106"
for %%i in (%list%) do (
net use "\\%%i\IPC$ /user:user password
copy "C:\Desktop\Update" "\\%%i\foldername"
net use /d "\\%%i\IPC$ /user:user password
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.