0
我有一個問題。我需要在每個循環中向vbscript中引入一些同步命令(一個Run方法,刪除一個並移動一個文件)到我的循環中。我不知道我是怎麼做到的。同步運行方法vbscript
我的代碼是:
Public Function UnificarCRIs(ByVal path, ByVal FICRIEC, ByVal sessio, ByVal CIBAA)
Dim objFile, objCurrentFolder, filesys, origenFitxers
Dim FileName, WshShell
On error resume next
Set filesys = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objCurrentFolder = filesys.getFolder(path)
For Each objFile In objCurrentFolder.Files
FileName = objFile
If (right(FileName, 4) = ".cri") Then
If filesys.FileExists(path & FICRIEC & sessio) Then
'WshShell.Run ("copy " & path & FICRIEC & sessio & "+" & FileName & " " & path & FICRIEC & sessio & "_tmp")
WshShell.run ("cmd /K " & "copy /Y " & path & FICRIEC & sessio & "+" & FileName & " " & path & FICRIEC & sessio & "_tmp",8,TRUE)
Set WshShell = Nothing
filesys.DeleteFile path & FICRIEC & sessio
'filesys.MoveFile path & FICRIEC & sessio & "_tmp", path & FICRIEC & sessio
Else
WshShell.run "cmd /K " & "copy /Y " & FileName & " " & path & FICRIEC & sessio,8,TRUE
Set WshShell = Nothing
End If
End If
Next
End Function
我已閱讀.Run和bWaitOnReturn參數的文檔,我認爲我已經很好。我的方法是:WshShell.run「cmd/K」&「copy/Y」&path_and_name_file_INPUT_1「+」&path_and_name_file_INPUT_2&「」&path_and_name_fileOUTPUT 1,TRUE – user2069014 2013-02-14 11:03:12
我發現了這個錯誤。我刪除了「On Errror Resume Next」和「Set WshShell = Nothing」,它正在工作!謝謝!!! ;-D – user2069014 2013-02-14 12:17:27