[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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

Posted on 2004-03-23
Medium Priority
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
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 (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.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

Industry Leaders: 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!

Question has a verified solution.

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

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

656 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