VBScript FileSystemObject.CopyFile() 到远程计算机找不到路径

VBScript FileSystemObject.CopyFile() to remote computer Path Not Found

这是一个简单的脚本,但我无法按照我想要的方式工作:

Const Overwrite = True
remoteHost = "DESKTOP1"
sDestination = "\" & remoteHost & "\C:\Users\betsy\Desktop\"
sSource = ".transferFile.txt"

Wscript.Sleep 2000

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile sSource ,sDestination, Overwrite

msgbox "The file sent: " & sDestination & "."

这给了我 Path not found。非常混乱。为什么它不给我 Permissions Denied 呢?当我真正坐在 Betsy 的电脑前时,路径正好是 C:\Users\betsy\Desktop\。此路径绝对 确实 存在于远程计算机上 - 我已经检查了 100 次。也许我的 sDestination 字符串格式不正确?

当我将 sDestination 更改为这个时它起作用了...

sDestination = "\" & remoteHost & "\Desktop1-Share\"

...但它不在正确的位置。

P.S。 \DESKTOP1\Desktop1-Share\ 是在远程计算机上配置的共享文件夹,但我需要将文件发送到我的奶牛 Betsy 的桌面文件夹 \DESKTOP1\c:\Users\betsy\Desktop,希望不配置共享文件夹。

此脚本的全部意义在于将文件复制到 1 台或多台远程计算机,而无需亲自坐在它们旁边。我实际上有数百台计算机可以执行此操作,但只需要向自己证明至少可以对一台远程计算机执行此操作。

路径 \<hostname>\C:\Users\betsy\Desktop\ 无效。主机名后的部分应该是 C$(自动创建的 administrative share,只有管理员可以访问),或者它应该是一个完全不同的名称 and/or 路径,如果你手动共享了目标文件夹或其下一个祖先。

以上内容适用于 XP。在 Vista+ 中,access to administrative shares is prohibited by default unless the machine is in a domain and the user is a domain admin. It can be re-enabled by hand

  • 按照 is a more manageable way. Under it, an accessing user will only see profiles and folders in them that the owner chose to share with them 中的建议使用新的 Users 共享(从技术上讲,他们具有读取和执行权限)。

你试过了吗

sDestination = "\" & remoteHost & "\Users\betsy\Desktop\"