Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript for copying file runs indefinitely

Status
Not open for further replies.

richardii

Programmer
Jan 8, 2001
104
GB
I have some vbscript for copying a file - it works fine when I double-click it. However, if I try to put it under control of the Scheduled Tasks (in Windows 2000) - the task runs indefinitely (and is never successful).

I've tried recoding the vbscript (as a shell call and using .CopyFile). Same result.

I guess the issue is with the Scheduler...anyone seen this before, know a solution?

Thanks.


'path is the path to the builds

path ="\\dragon\Releases\2.3SP1"
Set oFSO = CreateObject("scripting.filesystemobject")
location = oFSO.GetAbsolutePathName(path)

Deploy_from(location)


Function Deploy_from(s)
Dim aDate
Dim aName
Dim oFldr,oSubFldr
Dim cFldr
Dim iCnt
Dim n,m,temp

Set oFldr = oFso.GetFolder(s)
Set cFldr = oFldr.SubFolders

'ReDim array to number of folders
ReDim aDate(oFldr.SubFolders.Count)

iCnt = 1

'Add date creation (and only for the client folders)
For Each oSubFldr in cFldr
aDate(iCnt) = oSubFldr.Datecreated
iCnt = iCnt + 1
Next


'Sorting array by date, ascending sort order
For n = 0 to UBound(aDate) -1
For m = n+1 to UBound(aDate)
If aDate(m) < aDate(n) Then
temp = aDate(m)
aDate(m) = aDate(n)
aDate(n) = temp
End If
Next
Next

MaxDate = aDate(iCnt-1)


For Each oSubFldr in cFldr
If oSubFldr.Datecreated = MaxDate then
MaxName = oSubFldr.name
end if

Next


'now we have the directory most recently created
'we can use that ear file and deploy it
'Msgbox Maxname &" "& MaxDate


Set objFSO = CreateObject("scripting.filesystemobject")


'copy the new ear
sToCopyFrom = "\\dragon\Releases\2.3SP1\"& Maxname & "\WebConnect.ear"
sToCopyTo = "C:\bea\user_projects\domains\WebConnect\myserver\upload\"

objFSO.CopyFile sToCopyFrom , sToCopyTo, True

End Function


 
Try host the script with cscript.exe explicitly. Also mind the starting directory in case your .vbs file is not in the searching path.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top