10-11-2007 02:45 AM
10-11-2007 12:11 PM
03-11-2021 05:17 PM
I tried the method mentioned but I got an error back from TestStand that says "This function does not have parameter information in the DLL or uses types not recognized by TestStand". I'm using ver. 2019. Is there a workaround for that?
03-16-2021 08:18 AM - edited 03-16-2021 08:20 AM
Hello,
I know two way of handling process. Command lines and .Net Process.
With command line, it is possible to query the list of the running processes using tasklist command, and to identify by name a process, in order to retrieve its ID.
For example :
C:\Users\me>tasklist /FI "IMAGENAME eq explorer.exe"
Nom de l’image PID Nom de la sessio Numéro de s Utilisation
========================= ======== ================ =========== ============
explorer.exe 6200 Console 1 202 120 Ko
As you may guess, I'm using a french OS with accentuated caracters. That's mainly command line parsing, that you can manager with TestStand Expression (not really funny, I agree). Note you can use the /FO parameters to format the output as a list or csv (here as cvs) :
C:\Users\me>tasklist /FI "IMAGENAME eq cmd.exe" /FO csv
"Nom de l’image","PID","Nom de la session","Numéro de session","Utilisation mémoire"
"cmd.exe","10260","Console","1","5 864 Ko"
"cmd.exe","10464","Console","1","5 864 Ko"
"cmd.exe","1876","Console","1","9 676 Ko"
If you have several instances of the same executable, you may want to know who is who (here, 3 times cmd.exe). Nothing impossible if you are initiating the process (check who is running, run the new process, identify the new one's PID).
On the other hand, you also can use .Net Process from System.Diagnostics to manage execution of another process. But you will have to manage references. I used this in LabVIEW code, JKI exposes a package for VIPM that wrapps the whole think quite nicely : JKI .NET System Exec Toolkit for LabVIEW. If you are familiar with LabVIEW, it may be a good source of inspiration to implement something using .Net adapter in TestStand.
Hope this helps,