基本上,我想做这样的事情(仅使用命令提示符作为可视化示例,很乐意尝试使用PowerShell / VBScript /其他编程方法)...
xcopy "\\thisserver\share\something.txt" "\\computer1\c$\users\dude\Desktop\*.*" /Y
xcopy "\\thisserver\share\something.txt" "\\computer2\c$\users\dudeette\Desktop\*.*" /Y
...
事实上,如果我可以更进一步简化代码,我想做这样的事情:
xcopy "\\thisserver\share\something.txt" "\\computer1\c$\*\*\Desktop\*.*" /Y
xcopy "\\thisserver\share\something.txt" "\\computer2\c$\*\*\Desktop\*.*" /Y
我知道这是不正确的编码,但实际上我想将一个文件(确切地说是.vbs文件)从一个易于访问的网络位置复制到所有网络上的所有Windows用户(c:\ users)桌面位置我们域内的计算机。
非常感谢任何帮助!如果手动是唯一的选择,那我猜它就是这样。
答案 0 :(得分:2)
答案 1 :(得分:0)
如果您想尝试PowerShell:
<强> E:\共享\ Paths.txt 强>:
\\computer1\c$\users\dude\Desktop
\\computer2\c$\users\dudeette\Desktop
在 PowerShell :
中ForEach ( $destination in Get-Content -Path 'E:\share\Paths.txt' )
{
mkdir $destination -Force
Copy-Item -LiteralPath 'E:\share\something.txt' -Destination "$destination\something.txt" -Force
}
注意:
- I only tested this on the local drives
- if all destination folders exist: comment out "mkdir $destination -Force"
(place a "#" before the line: "# mkdir $destination -Force")
- if destination paths contain spaces place this line above "mkdir" line
$destination = $destination.Replace("`"", "`'")
- I didn't test paths with spaces either
- You can rename destination file to "somethingElse.txt" in the "Copy-Item" line:
... -Destination "$destination\somethingElse.txt" -Force
所以,版本2:
ForEach ( $destination in Get-Content -Path 'E:\Paths.txt' )
{
$destination = $destination.Replace("`"", "`'")
# mkdir $destination -Force
Copy-Item -LiteralPath 'E:\share\something.txt' -Destination "$destination\somethingElse.txt" -Force
}