Hi
The following script works OK when run interactively from the command
line, but when run as a scheduled task - via SQL Enterprise Manager in
preperation for another SQL task - returns the error:-
The process could not be created for step 2 of job
0x0882C8212587254BB055CCD056C84FD0 (reason: %1 is not a valid Win32
application). The step failed.
The VB script is as follows, and it fails before the copy operation:-
dim yr
dim mth
dim day
dim objFile
dim objFso
dim objFolder
dim objFileLoop
yr = cstr(4)
mth =cstr(2)
day = cstr(2)
file = cstr(51)
yr = datepart("yyyy",Now)
mth = datepart("m",Now)
day = datepart("d",now)
if mth = "1" then
mth = "01"
end if
if mth = "2" then
mth = "02"
end if
if mth = "3" then
mth = "03"
end if
if mth = "4" then
mth = "04"
end if
if mth = "5" then
mth = "05"
end if
if mth = "6" then
mth = "06"
end if
if mth = "7" then
mth = "07"
end if
if mth = "8" then
mth = "08"
end if
if mth = "9" then
mth = "09"
end if
if day = "1" then
day = "01"
end if
if day = "2" then
day = "02"
end if
if day = "3" then
day = "03"
end if
if day = "4" then
day = "04"
end if
if day = "5" then
day = "05"
end if
if day = "6" then
day = "06"
end if
if day = "7" then
day = "07"
end if
if day = "8" then
day = "08"
end if
if day = "9" then
day = "09"
end if
set objFso = createobject("scripting.FileSystemObject")
objFile = "AGRESSODB01_agresso_Full_" & yr & mth & day & "2200 (1 of
1).safe"
if objFso.FileExists(objFile) then
objFso.CopyFile objFile, "\\agressodr\e$\sqlsafe
\AGRESSODB01_Live_Full.safe"
end if
set objFso = Nothing
set objFso = createobject("scripting.FileSystemObject")
set objFolder = objFso.GetFolder("J:\SqlSafe")
for each objFileLoop in objFolder.Files
if datediff("d",objFileLoop.DateCreated,Now) > 7 then
objFile = objFileLoop.Name
if objFileLoop.Name <> "CopyFile.vbs" then
objFso.DeleteFile(objFile)
end if
end if
next
Any assistance appreciated