Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
stefan_schnell
Active Contributor
0 Kudos
2,917


In a few posts we discuss the possibility to use multiple VBScript processes. With the Run command you can start different processes asynchronously. But after the start, you have not really a chance to synchronize the processes. Maybe via a file interface. For the process synchronization and communication offers Windows the IPC interface (Interprocess Communication).

There are different technics to synchronize and to communicate between processes, like

  • Events,

  • Semaphores,

  • FileMaps and

  • the ClipBoard

  • etc.


To use this possibilities I programmed a COM library which offers this technics. You find it here.

With COMIPC you can easily e.g. synchronize processes, look at the following example:
'-Begin-----------------------------------------------------------------

'-Directives----------------------------------------------------------
Option Explicit

'-Constants-----------------------------------------------------------
Const INFINITE = -1

'-Variables-----------------------------------------------------------
Dim oIPC, hEvent, wsh, extVBS, rc

'-Main----------------------------------------------------------------
Set oIPC = CreateObject("COMIPC")
If IsObject(oIPC) Then

hEvent = oIPC.EventCreate("TestEvent", 0, 0)

If hEvent Then

extVBS = "Script 2.vbs"
Set wsh = CreateObject("WScript.Shell")
If IsObject(wsh) Then
wsh.Run("wscript.exe " & extVBS)
Set wsh = Nothing
End If

rc = oIPC.EventWait("TestEvent", INFINITE)
rc = oIPC.EventClose(hEvent)

End If
Set oIPC = Nothing
End If

MsgBox "End"

'-End-------------------------------------------------------------------

 

We create an event, start a second script and wait until the event is set in the second script.
'-Begin-----------------------------------------------------------------

'-Directives----------------------------------------------------------
Option Explicit

'-Variables-----------------------------------------------------------
Dim oIPC, rc

'-Main----------------------------------------------------------------
Set oIPC = CreateObject("COMIPC")
If IsObject(oIPC) Then

MsgBox "Event"

rc = oIPC.EventSet("TestEvent")
Set oIPC = Nothing
End If

'-End-------------------------------------------------------------------

 

If the event is set, in the second script, the first script will finish.

So it is e.g. possible to start different SAP GUI Scripts and to set different synchronization points. Also you can communicate between different processes via FileMap - File mapping is the association of a file's contents with a portion of the virtual address space of a process.

Enjoy it.

3 Comments
Labels in this area