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

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 doc.save (True, True)
      Call workspace.EditDocument(True, doc)      
End Sub
Question by:kwaing
  • 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 (kcpauli@usa.net)
  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.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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