试图简化我拥有的这个 .bat 文件。
我在多个客户端上有一个 .bat 文件,用户从执行特定任务的快捷方式运行该文件。在某些日子里,我需要修改所有远程客户端上的 .bat 文件。
我只想在一个位置修改 .bat 文件(保持其名称相同),然后通过自己运行 .bat 文件将修改后的文件发送给所有客户端(覆盖现有副本)。
这是我到目前为止所拥有的。我想要一种更优雅的方式来做到这一点。也许创建一个文件以与所有客户端一起读取,然后 .bat 文件可能会执行“for循环”,但我不知道。
@echo on
SET client1=\\deptpc1\c$\dicom
SET client2=\\deptpc2\c$\dicom
SET client3=\\deptpc3\c$\dicom
SET client4=\\deptpc4\c$\dicom
SET client5=\\deptpc5\c$\dicom
SET client6=\\deptpc6\c$\dicom
SET client7=\\deptpc7\c$\dicom
SET client8=\\deptpc8\c$\dicom
SET client9=\\deptpc9\c$\dicom
SET client10=\\deptpc10\c$\dicom
SET client11=\\deptpc11\c$\dicom
SET client12=\\deptpc12\c$\dicom
SET sandbox=\\SERVER\sandbox$\backups\scripts
goto code
this file deletes the .bat file in the dicom dir and copies the .bat file from \\server\sandbox$\backups\scripts\A2
for each CD ripper PC
:code
net use %client1% Pa$$worm /user:deptpc1\user1
net use %client2% Pa$$worm /user:deptpc2\user1
net use %client3% Pa$$worm /user:deptpc3\user1
net use %client4% Pa$$worm /user:deptpc4\user1
net use %client5% Pa$$worm /user:deptpc5\user1
net use %client6% Pa$$worm /user:deptpc6\user1
net use %client7% Pa$$worm /user:deptpc7\user1
net use %client8% Pa$$worm /user:deptpc8\user1
net use %client9% Pa$$worm /user:deptpc9\user1
net use %client10% Pa$$worm /user:deptpc10\user1
net use %client11% Pa$$worm /user:deptpc11\user1
net use %client12% Pa$$worm /user:deptpc12\user1
copy /v/y %sandbox%\A2\*.bat %client1%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client2%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client3%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client4%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client5%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client6%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client7%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client8%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client9%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client10%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client11%\c$\dicom
copy /v/y %sandbox%\A2\*.bat %client12%\c$\dicom
net use /d %client1% /y
net use /d %client2% /y
net use /d %client3% /y
net use /d %client4% /y
net use /d %client5% /y
net use /d %client6% /y
net use /d %client7% /y
net use /d %client8% /y
net use /d %client9% /y
net use /d %client10% /y
net use /d %client11% /y
net use /d %client12% /y
exit
感谢您的关注!