我在运行SQL代理一个VBScript,但我得到的线34“权限被拒绝”(第一个副本的尝试)。我已经运行SQL代理超出这个脚本,没有任何问题。

供参考:在 'X:\' 驱动器映射到一个SharePoint文件夹。这可能是罪魁祸首。

Function Main()
Const SourceDrive As String = "X:\"
Dim fso
Dim Today
Dim FileName
Dim FromFile
Dim FromDrive
Dim ArchivePath

Set fso = CreateObject("Scripting.FileSystemObject")

Today = Format(Now, "yyyyMMdd")

'To add more sources just add them to the array list
Dim Sources() As Variant
Sources() = Array("Item1", _
                  "Item2")

'To add more targets just add them to the array list
Dim Targets() As Variant
Targets() = Array("C:\Users\myalias\Desktop\MyToFolder", _
                  "C:\Users\myalias\Desktop\MyToFolder2")


For i = 0 To UBound(Sources)
    FileName = "WebSurveyAlertCallbacks_" & Sources(i) & "_" & Today & ".xls"
    FromDrive = fso.BuildPath(SourceDrive, Sources(i))
    FromFile = fso.BuildPath(FromDrive, FileName)
    ArchivePath = fso.BuildPath(FromDrive, "Archive")
    If fso.FileExists(FromFile) Then
        For t = 0 To UBound(Targets)
            fso.CopyFile FromFile, fso.BuildPath(Targets(t), FileName), True
        Next
        fso.CopyFile FromFile, fso.BuildPath(ArchivePath, FileName), True
        fso.DeleteFile FromFile
    End If
Next

Set fso = Nothing

Main = DTSTaskExecResult_Success
End Function
有帮助吗?

解决方案

该代理可能是不同的用户帐户下运行(即,不你),然后不具有权限的文件/文件夹您使用。

当你在外面跑,它使用您的登录用户的权限,并执行罚款。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top