You can acquire all process data of all opened CATStart sessions with WMI-Scripting.

Bas-Modul here. Copy the code to a VBA-modul.

The result looks like this:

Here's the code:


Sub CATMain()
   Dim Process As Object
   Dim arrArgs() As String
   Dim strTmp As String
   Dim n As Integer
   Dim strEnv As String
   Dim strEnvDir As String
   Dim strDummy As String

   'use wmi-scripting to find all processes where caption is 'CATStart'; read all process info
   'check https://msdn.microsoft.com/de-de/library/ms974579.aspx#ID0ESC for more info
   For Each Process In GetObject("winmgmts:").ExecQuery("Select * from Win32_Process where caption='CATSTART.EXE'")
      strDummy = Replace(Process.CommandLine, Chr(34), Chr(32))   'get rid of ' " '
      arrArgs = Split(strDummy, "-")                       'split commandline into single parms
      For n = 0 To UBound(arrArgs)
         strTmp = strTmp & vbCrLf & "Arg " & CStr(n) & ": " & arrArgs(n)
         If InStr(arrArgs(n), "direnv") Then               'find environ dir
            strEnvDir = Trim(Right(arrArgs(n), Len(arrArgs(n)) - Len("direnv")))
         ElseIf InStr(arrArgs(n), "env") Then              'find environ file
            strEnv = Trim(Right(arrArgs(n), Len(arrArgs(n)) - Len("env")))   'trim the blanks
         End If
      Next
      MsgBox "Process caption: " & Process.Caption & vbCrLf _
           & "Process command line arguments: " & strTmp & vbCrLf & vbCrLf _
           & "Environment: " & strEnv & vbCrLf _
           & "Environment Dir: " & strEnvDir & vbCrLf _
           & "Process handle: " & Process.Handle & vbCrLf _
           & "Creation date: " & Left(Process.creationdate, 8) & vbCrLf _
           & "Creation time: " & Mid(Process.creationdate, 9, 6), _
             vbOKOnly Or vbInformation, "Catia V5 Process Information"
      strTmp = ""
   Next
   If strDummy = "" Then                                   'no commandline(no catstart;no parms)
      MsgBox "CATSTART.exe not found" & vbCrLf _
           & "No environment detected.", _
             vbOKOnly Or vbCritical, "Get Catia Command Line Arguments"
   End If

End Sub


 

Go to top