By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,379 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,379 IT Pros & Developers. It's quick & easy.

Identifying which WINWORD process to proc.kill()

P: 2
I am extremely new to C#, so please respond using small words. :-) I am working on a client/server application which creates a word document and attaches it to an e-mail. Once the e-mail is sent, I need to kill the WINWORD process on the server. Unfortunately, everyone who uses this application is running under the same credentials, so I can not identify the correct process based on the user name. The session number does not seem to be unique either. I am thinking that I need to "catch" the PID for the WINWORD process as soon as it is started, and then reference that PID when I am ready to use proc.kill(). I am not certain how to get the PID when the process first kicks off, though. Any thoughts or suggestions would be appreciated.
Mar 17 '08 #1
Share this Question
Share on Google+
1 Reply


P: 2
I am extremely new to C#, so please respond using small words. :-) I am working on a client/server application which creates a word document and attaches it to an e-mail. Once the e-mail is sent, I need to kill the WINWORD process on the server. Unfortunately, everyone who uses this application is running under the same credentials, so I can not identify the correct process based on the user name. The session number does not seem to be unique either. I am thinking that I need to "catch" the PID for the WINWORD process as soon as it is started, and then reference that PID when I am ready to use proc.kill(). I am not certain how to get the PID when the process first kicks off, though. Any thoughts or suggestions would be appreciated.
To follow up on this post, I have found a way to handle this issue. When the word document is created, I "grab" all of the procedures named "WINWORD", specifically the Process ID(PID) and the Start Time. I dump these into an array. Then I spin through the array doing a "bubble sort" to find the most recent start time (it is provided in a dateTime format). This provides me with the most recent process, which is the one that was just created. I save the PID in a session variable. Once I am finished with the document, I can then select the process based on the PID in my session variable and kill that specific process, while leaving everyone else's WINWORD processes alone.
Mar 18 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.