Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1190
  • Last Modified:

Lotus Script to be excute only after an exe program ended...

HI I am having much headach with this, I've very new to lotus script . I have a VB program which create files inside a temp folder inside the c:\ and what the lotus script needs to do is. Create an agent that call my exe program then after the program ends get the files that the exe created inside the temp folder and attach it to the new memo that the user have already created.

 I have tried the Yeild function and apparently the win3.1 API doesn't support the w2k and its a big mess here. Please help.

Below is my code. What its doing now is it doesn't wait untill the shell program ends, the message box pops up imideately when the program is called and I don't want it that way. Msg box is my temporarily solution to halt the script.

Sub Initialize
      Dim session As New NotesSession
      Dim curdb As NotesDatabase
      Dim workspace As New NotesUIWorkspace
      Dim rtitem As NotesRichTextItem
      Dim object As NotesEmbeddedObject
      Dim chk As Boolean
      Dim result As Integer
      result = Shell ( "C:\test.exe", 1)
      Msgbox "Please click on OK when you have selected the Documents to be Attached."
      Set curdb = session.CurrentDatabase
      Dim doc As New NotesDocument (curdb)
      Set rtitem = doc.CreateRichTextItem( "Body" )      
      Dim pathName As String, fileName As String
      pathName$ = "C:\Temp\"
      fileName$ = Dir$(pathName$, 0)
      Do While fileName$ <> ""
            Msgbox fileName$
            Set object = rtitem.EmbedObject( EMBED_ATTACHMENT, "",pathName$&fileName$ )            
            Kill pathName$&fileName$            
            fileName$ = Dir$()
      doc.Form = "Memo"      
      Call (True, True)
      Call workspace.EditDocument(True, doc)      
End Sub
  • 4
  • 2
1 Solution
From Designer help:

After Shell starts a program, LotusScript continues to execute the script without waiting to make sure the program has completed. You cannot be sure that a program started by Shell has finished running before the rest of your script is executed.

Do you have the VB source code?
In that case, can you make it to create some kind of a trigger file when it is done?
LS yould wait in a loop until that file if found (and delete it).
The rest of the code is then allowed to execute.
kwaingAuthor Commented:
HI, I think I have solved my problem myself...

and thought i'd share with you all...

  cb As Long
  lpReserved As String
  lpDesktop As String
  lpTitle As String
  dwX As Long
  dwY As Long
  dwXSize As Long
  dwYSize As Long
  dwXCountChars As Long
  dwYCountChars As Long
  dwFillAttribute As Long
  dwFlags As Long
  wShowWindow As Integer
  cbReserved2 As Integer
  lpReserved2 As Long
  hStdInput As Long
  hStdOutput As Long
  hStdError As Long
End Type

  hProcess As Long
  hThread As Long
  dwProcessID As Long
  dwThreadID As Long
End Type

Declare Function WaitForSingleObject Lib "kernel32" (Byval _
  hHandle As Long, Byval dwMilliseconds As Long) As Long

Declare Function CreateProcessA Lib "kernel32" (Byval _
  lpApplicationName As Long, Byval lpCommandLine As String, Byval _
  lpProcessAttributes As Long, Byval lpThreadAttributes As Long, _
  Byval bInheritHandles As Long, Byval dwCreationFlags As Long, _
  Byval lpEnvironment As Long, Byval lpCurrentDirectory As Long, _
  lpStartupInfo As STARTUPINFO, lpProcessInformation As _

Declare Function CloseHandle Lib "kernel32" (Byval _
  hObject As Long) As Long

Public Const INFINITE = -1&

Public Sub ShellAndWait(Byval RunProg As String)
  ' From Kevin Pauli (
  Dim RetVal As Long
  StartInf.cb = Len(StartInf)
  'Execute the given path
  RetVal = CreateProcessA(0&, RunProg, 0&, 0&, 1&, _
  NORMAL_PRIORITY_CLASS, 0&, 0&, StartInf, proc)

  'Disable this app until the shelled one is done
  RetVal = WaitForSingleObject(proc.hProcess, INFINITE)
  RetVal = CloseHandle(proc.hProcess)
End Sub

Thank you for your input CRAK!!!!

Thanks for sharing that! It's certainly worth bookmarking!
Do realize that you restrict yourself to certain versions of Windows only!

In Win 3.x I once had to use Windows' OpenFile dialog. Can't remember the DLL it came from or other details, but it had the limitation of being unable to run on a vast no. of clients (running OS/2).
Later, when Win 3.x was replaced with Win2000 (Y2K related upgrade), we needed to rewrite the code again, as the DLL changed.
Since then, I generally prefer the implementation of cross-platform solutions, just like Notes itself is. A trigger file can provide just that, although is kind of a silly way to control a program.

So you've solved it yourself. Well done!
You do need to finalize the question though.... If you post a link under community support, you can ask to close it for you and refund the points.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

I have become Page Editor for this topic area.
If you like I could close this question for you and refund your points.


Page Editor
kwaingAuthor Commented:
Thank you CRAK,

I wasn't really sure how to request for the closing of this topic.

Please do so.

Question closed with user's consent; points (50) refunded.

Page Editor
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now