使用VBScript拒绝权限

时间:2011-06-02 21:46:40

标签: vbscript

我有一个可以移动和重命名文件夹的脚本。它在本地运行时是成功的,但是当尝试使用映射驱动器读取或写入目录时,该过程失败并显示“权限被拒绝”错误。

VBScript不喜欢映射驱动器吗?下面是具有读取和写入源和目标的凭据的脚本:

dim objNetwork

Set objNetwork = WScript.CreateObject("WScript.Network")
strLocalDrive = "Y:"
strRemoteShare = "\\servername\directory"
strPer = "False"
strUsr = "userid"
strPas = "password"
objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, strPer, strUsr, strPas

Dim fso, objFol, objMoveFol, strPathBuild

Set fso = CreateObject("Scripting.FileSystemObject")
Set objFol = fso.GetFolder("D:\Source")

For Each objMoveFol In objFol.SubFolders

    'Replace the root folder locations in the path
    strPathBuild = Replace(objMoveFol, "D:\Source", "Y:\Destination")

    'Do the required other fiddle
    strPathBuild = Replace(strPathBuild, "A.", "Ack~")

    fso.Movefolder objMoveFol, strPathBuild

Next

1 个答案:

答案 0 :(得分:0)

代码看起来很好。此外,如果它在本地工作,我猜你正在映射网络驱动器的用户没有编辑该文件夹的权限。

尝试使用相同的用户名和密码手动映射驱动器。将文件夹复制到同一位置以检查用户权限