BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello, everybody. Sorry for my terrible english in advance. I hope, you'll help find me find out, what am i doing wrong)

I have a project, which i want to run by schedule. EG created default VBscript (Tools->Schedule Project how it was written in manual).

Option Explicit
Dim app

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
Dim prjObject

prjName = "C:\SAS\sending_test.egp" 'Project Name

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

'-----
' open the project
'-----
Set prjObject = app.Open(prjName,"")
If Checkerror("app.Open") = True Then
Exit Sub
End If


'-----
' run the project
'-----
prjObject.run
If Checkerror("Project.run") = True Then
Exit Sub
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
Dim errNum

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


When i' m trying to run this script, nothing happens!

I tried to delete error check from my script, ones again run it and recieved th message from Windows Script Host: Unable to connect to server: SASMain.
So to run project i'm forced to push the button "run branch from .... task", then enter login and password to connect to server! Is it possible to correct my script so, that connection to server and running of my tasks occurs automatic?

Thank you!
2 REPLIES 2
deleted_user
Not applicable
Hi Tano,

Have you seen this SAS-Note?: http://support.sas.com/techsup/unotes/SN/014/014700.html
In the bottom you'll find a link to the OLE Automation Guide, which is the engine for EG Scheduling.

Anyhow, I do not know anything about Visual Basic programming, so I'll just assume that you wrote everything right; what I do know is that to schedule an EG project you should create (if EG doesn't do it for you), an Scheduled Task in Windows Control Panel.

Identify the task that corresponds to your Project and set the USERID & PASSWORD you'll use in there. If you're working on a remote SAS server, make sure that your UserId starts with the Windows Domain. i.e. domain\userid.

PS: If you double-click on the task and it doesn't run immediatly, it means that there's something wrong with the code.

Cheers
SteUpenn
Calcite | Level 5

Hi,

I am having the same issue where you able to resolve it?

Thanks,

Stephanie

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 2686 views
  • 0 likes
  • 2 in conversation