Analytic Lunatic
Analytic Lunatic

Reputation: 3934

Check if WINWORD.EXE Process is Running?

I've got a C# Winforms Application that processes queried data into Mail Merge documents. How can I check on application start-up to see if current user has a Microsoft Word Instance Open, and if so, alert them to close before proceeding?

Upvotes: 2

Views: 2893

Answers (2)

gleng
gleng

Reputation: 6304

Use LINQ Any:

var isRunning = Process.GetProcessesByName("winword").Any();

Upvotes: 3

realnero
realnero

Reputation: 994

Process[] processes = Process.GetProcessesByName("winword.exe");
if (processes.Length == 0)
//not running
else
//running

Upvotes: 2

Related Questions