  | 
			
				SoftTree Technologies 
				Technical Support Forums
			 | 
		 
		  | 
	 
	 
	
	
	
		
	
	
	
		| Author | 
		Message | 
	 
	
		
			jwww001 
			 
			
  
			
			
				Joined: 13 Feb 2012 Posts: 8 Country: Hong Kong | 
			 
			  
		 | 
		
			
				  Schedule job cannot end | 
				     | 
			 
			
				I created a job to run the following vbscript. I can see the message "Exit1" and the script completed. However, I still can see the job is running in the job monitoring screen. This cause the subsequent jobs can not be started. Do you have any ideas why?
 
 
 
Option Explicit
 
Dim app
 
 
Call dowork
 
 
'shut down the app
 
If not (app Is Nothing) Then
 
    app.Quit
 
    'Set app = Nothing
 
    MsgBox "Exit1"
 
    WScript.Quit
 
End If
 
 
Sub dowork()
 
    On Error Resume Next
 
    '----
 
    ' Start up Enterprise Guide using the project name
 
    '----
 
    Dim prjName
 
    Dim prjObject
 
 
    prjName = "C:\project.egp"    'Project Name
 
      
 
    Set app = CreateObject("SASEGObjectModel.Application.4.2")
 
    app.SetActiveProfile("CCR")
 
	MsgBox "1"
 
    If Checkerror("CreateObject") = True Then
 
        Exit Sub
 
    End If
 
    
 
    '-----
 
    ' open the project
 
    '-----
 
    Set prjObject = app.Open(prjName,"")
 
	MsgBox "2"
 
    If Checkerror("app.Open") = True Then
 
        Exit Sub
 
    End If
 
    
 
        
 
    '-----
 
    ' run the project
 
    '-----
 
	MsgBox "3"
 
    prjObject.run
 
	MsgBox "4"
 
    If Checkerror("Project.run") = True Then
 
        Exit Sub
 
    End If
 
    
 
            
 
    '-----
 
    ' Save the new project
 
    '-----
 
	MsgBox "5"
 
    prjObject.Save
 
	MsgBox "6"
 
    If Checkerror("Project.Save") = True Then
 
        Exit Sub
 
    End If
 
    
 
    '-----
 
    ' Close the project
 
    '-----
 
	MsgBox "7"
 
    prjObject.Close
 
	MsgBox "8"
 
    If Checkerror("Project.Close") = True Then
 
        Exit Sub
 
    End If
 
    Set prjObject = Nothing   
 
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
  | 
			 
		  | 
	 
	
		| Mon Feb 13, 2012 6:05 am | 
		          | 
	 
	
		  | 
	 
	
		
			SysOp 
			Site Admin 
			
  
			
			
				Joined: 26 Nov 2006 Posts: 7992
  | 
			 
			  
		 | 
		
			
				   | 
				     | 
			 
			
				It looks like one of the objects you created is not getting destroyed, locking resources and holding the entire job in the running state
 
 
For example
 
 
	  | 
	
 
	  | 
	'----- 
 
' Save the new project 
 
'----- 
 
MsgBox "5" 
 
prjObject.Save 
 
MsgBox "6" 
 
If Checkerror("Project.Save") = True Then 
 
Exit Sub 
 
End If | 
	 
 
 
 
 
the code above checks for an error  Checkerror("Project.Save") = True and exits leaving prjObject running. Please try adding Set prjObject = Nothing to the Checkerror function.
  | 
			 
		  | 
	 
	
		| Tue Feb 21, 2012 9:28 am | 
		          | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
	 
	    
	   | 
	
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
  | 
   
 
		 | 
	 
	  |