0

I'm new to programming. I've made a simple codeblock that runs a Windows program POSTOPEN when I open an application in Lotus Notes 8.5.3 (basic)

' [ML]Check if user is member of the [ConnectClient] role. 
ipConnect = HasRole("[ConnectClient]") 
If ipConnect = True Then 
    Dim result As Integer
    Print "Postopen: Has [ConnectClient] role - starting Connect Client"
    result = Shell("c:\program files (x86)\ipvision\Connect\connect.exe", 1) 
End If

Is there any way for Lotus Script to check if a Windows process is already running?

Thanks

Morten Laustsen
  • 527
  • 4
  • 13
  • 25

2 Answers2

1

Use Shell to run tasklist and direct the output to a file. Then read the file in LotusScript and check if the process is listed there.

edit

Looks like you can even check if a specific process if running using tasklist:

tasklist /FI "IMAGENAME eq connect.exe" /FO CSV > search.log

How to check if a process is running via a batch script

Community
  • 1
  • 1
Panu Haaramo
  • 2,932
  • 19
  • 41
1

According to this snippet: http://blog.panagenda.com/pub/panablog.nsf/d6plinks/FLOR-7D5KZR I assume following code could work: http://coderstalk.blogspot.sk/2009/10/list-windows-xp-running-process-and.html

Option Explicit

Dim oProc, oWMIServ, colProc
Dim strPC, strList
Dim StrSpace

strPC = "."

Set oWMIServ = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPC & "\root\cimv2")    

Set colProc = oWMIServ.ExecQuery("Select * from Win32_Process")

strSpace = string(20," ")
strList = "ProcName" & strSpace & vbTab & "ProcID" & vbCrLf & string(45,"-")

For Each oProc In colProc
    strSpace = string(28 - len(oProc.Name)," ")
    strList = strList & vbCrLf & oProc.Name & strSpace & vbTab & oProc.ProcessId
Next

So once you have process ID (assuming you have ran your task by shellid function), execute chceck for all running processes and determine whether there is processid you have started.

BTW: the same approach can be used to terminate such process. Just google for >"winmgmts" lotusscript<.

Frantisek Kossuth
  • 3,524
  • 2
  • 23
  • 42