BookmarkSubscribeRSS Feed
Jonison
Fluorite | Level 6

Hello, I have built a process flow, and to schedule this task, i v build a order list as well, name 'orderlist' under 'ordered list'. To schedule this orderlist, I modified the schedule vbs as blow.

 

==========================

Option Explicit
Dim app ' As SASEGuide.Application

Call dowork

'shut down the app
If not (app Is Nothing) Then
app.Quit
Set app = Nothing
End If


Sub dowork()
On Error Resume Next
'----
' Start up Enterprise Guide using the project name
'----
Dim prjName ' As String
Dim prjObject ' As SASEGuide.Project
Dim containerName ' As String
Dim containerObject ' As SASEGuide.Container
Dim containerColl ' As SASEGuide.ContainerCollection

prjName = "C:\Users\xfx89651\250_50_Project.egp" ' Project Name
containerName = "OrderedList" ' Container Name

Set app = CreateObject("SASEGObjectModel.Application.7.1")
If Checkerror("CreateObject") = True Then
Exit Sub
End If

Set prjObject = app.Open(prjName,"")
If Checkerror("App.Open") = True Then
Exit Sub
End If


'-----
'Get The Container Collection and Object
'-----
Set containerColl = prjObject.ContainerCollection
If Checkerror("Project.ContainerCollection") = True Then
Exit Sub
End If

Dim i ' As Long
Dim j ' As Long
Dim count ' As Long
Dim count_OL ' As Long
count = containerColl.count
For i = 0 To count - 1
Set containerObject = containerColl.Item(i)
If Checkerror("ContainerCollection.Item") = True Then
Exit Sub
End If

If (containerObject.Name = "Ordered Lists") Then
count_OL = containerOjbect.items.count
For j = 0 to count_OL - 1
if Checkerror("ContainerCollection.Item") = True Then
Exit SUb
End if
Set orderedListObject = containerObject.items.item(j)
if (orderedListObject.name = containerName) then
exit for
Else
set orderedlistObject = Nothing
end if
Next
Exit For
Else
Set containerObject = Nothing
Set orderedListObject = Nothing
End If
Next

If not (containerObject Is Nothing) Then
'----
' Run the Container
'----
containerObject.Run
If Checkerror("Container.Run") = True Then
Exit Sub
End If
End If

'-----
' Save the new project
'-----
prjObject.Save
If Checkerror("Project.Save") = True Then
Exit Sub
End If

'-----
' Close the project
'-----
prjObject.Close
If Checkerror("Project.Close") = True Then
Exit Sub
End If

End Sub

Function Checkerror(fnName)
Checkerror = False

Dim strmsg ' As String
Dim errNum ' As Long

If Err.Number <> 0 Then
strmsg = "Error #" & Hex(Err.Number) & vbCrLf & "In Function " & fnName & vbCrLf & Err.Description
'MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
Checkerror = True
End If

End Function

 

====

 

 

a strange thing is that, when I execute the vbs and it can generate the output successfully. But, when I create schedule in EG and link the schedule with the vbs, the ouput is not successfully produced.

 

would experts can give me some suggestions on this?

 

Many thanks

 

 

 

2 REPLIES 2
fifthand57th
SAS Employee

@Jonison 

 

Check out the following SAS notes for EG Scheduling assistance:

http://support.sas.com/kb/59079

http://support.sas.com/kb/56648

 

Additionally, here's a webinar link that steps through the debug process:

https://communities.sas.com/t5/Ask-the-Expert/SAS-Enterprise-Guide-Scheduling-Projects/ta-p/506514

 

CaseySmith
SAS Employee

If it works as expected when you manually run the .vbs file, you are very close to having it working via scheduling.  Another thing to check is to make sure you are using the proper version of cscript.exe that matches your EG bitness.  For example, if you are using 32-bit EG, then the program/script on the Action tab in your Windows Scheduled task should be:

C:\Windows\SysWOW64\cscript.exe

 

If you are using 64-bit EG, it should be:

C:\Windows\System32\cscript.exe

 

In both cases, the "Add arguments" field should contain the quoted full path to your .vbs file.  For example:
"C:\fullPathToVBSFile\EGScript1.vbs"

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 881 views
  • 0 likes
  • 3 in conversation