I developed an app in VB.NET. It works well, but the end of the execution is not completely clean.
The application logs on to solidworks: swApp = New SldWorks
There's a whole lot going on...
Then I close the document: swApp.CloseDoc(sDocfilename)
There is still a lot going on and the program is coming to an end
Logically I have an empty solidworks window that remains open. If I close it by hand, I see that the SLDWORKS process then goes into the list of "background processes" with a "-Embedding" in the command line. I notice the same phenomenon if I add in the code: swApp.ExitApp() .
This solidworks session in the background causes new sessions to crash. So you have to kill him by hand.
To get out of this you can, at the end of the program, make a loop that lists all the active processes and "kill" the "SLDWORKS.exe" process(es), which is what I do on all my programs (C#) that drive Solidworks at one time or another.
I was wondering if there was a way for my application to list these child processes. But it doesn't look easy.
Killing all solidworks processes seems a bit brutal to me. My application is launched as a task (when a document is approved) and it would be a shame to kill the user's session.
I had already noticed it and it seemed complicated to me. I was hoping for something simpler and more straightforward in system.diagnostic.process or something like that.
If it seems too complex for your needs and since it's a safe bet that you'll encounter problems related to the rights needed to use these functions, you may be able to get around it all by going back to the first suggestion (To get out of it you can, at the end of the program, make a loop that lists all the active processes and "kill" the "SLDWORKS.exe" process(es) but only kill the process whose "MainWindowTitle" contains a certain value, a value that you can define by creating for example a room with a "weird" name before killing this process. This allows you to stay on simple and direct access in system.diagnostic.process.