fso 拒绝访问_VBS中对CopyFile的权限被拒绝

I'm trying to automate pushing a file into my users' home directories, but am stuck on a "Permission Denied" error — is thrown on line 6 here, with the CopyFile call.

There are other parts of the script (not shown) that create and copy folder contents using the same source and destination directories, and they work perfectly. It's only when I use CopyFile that it fails.

Dim fso

Set fso = CreateObject("Scripting.FileSystemObject")

If Not fso.FileExists("H:\Minecraft\.minecraft\options.txt") Then

fso.CopyFile "C:\Minecraft\options.txt", "H:\Minecraft\.minecraft\"

End If

Set fso = Nothing

H: is a network home directory, to which the current user has full read/write privs.

I've tried adding/removing trailing slashes from the paths, adding "options.txt" to the destination path, removing the false argument... Not sure what else to try. Any thoughts?

FYI, this chunk of code, which comes immediately before the error-prone bit above, executes perfectly every time:

If Not fso.FolderExists("H:\Minecraft\.minecraft\bin\") Then

If Not fso.FolderExists("H:\Minecraft\.minecraft\") Then

fso.CreateFolder("H:\Minecraft\.minecraft\")

End If

fso.GetFolder("C:\Minecraft\bin\").Copy "H:\Minecraft\.minecraft\"

End If

解决方案

I've only ever seen CopyFile fail with a "permission denied" error in one of these 3 scenarios:

An actual permission problem with either source or destination.

Destination path is a folder, but does not have a trailing backslash.

Source file is locked by an application.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值