0
我正在SQL代理中運行VBScript,但在第34行(第一次複製嘗試)中出現'權限被拒絕'。我在SQL Agent之外運行了這個腳本,沒有任何問題CopyFile上的VBScript權限被拒絕
僅供參考:'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
我傾向於同意這個答案,但代理使用與我正在使用的用戶相同的用戶登錄。 – 2010-06-09 19:09:55