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

Posted on 2004-03-23
Last Modified: 2010-04-22
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
Question by:kwaing
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 13

Expert Comment

ID: 10669391
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.

Accepted Solution

kwaing earned 0 total points
ID: 10701687
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!!!!

LVL 13

Expert Comment

ID: 10702036
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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 13

Expert Comment

ID: 10749070
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

Author Comment

ID: 10750982
Thank you CRAK,

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

Please do so.

LVL 13

Expert Comment

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

Page Editor

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question