检查特定的exe文件运行 [英] Check if a specific exe file is running

查看:368
本文介绍了检查特定的exe文件运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我可以在特定的位置检查程序是否正在运行。比如有针对的test.exe在C两个位置:\loc1\test.exe和c:\loc2\test.exe。我只是想知道,如果C:\loc1\test.exe正在运行,而不是test.exe的所有实例


解决方案

 布尔isRunning = Process.GetProcessesByName(测试)
.FirstOrDefault(p => p.MainModule.FileName.StartsWith(@C:\loc1) !)=默认的(过程);


I want to know how i can check a program in a specific location if it is running. For example there are two locations for test.exe in c:\loc1\test.exe and c:\loc2\test.exe. I only wanted to know if c:\loc1\test.exe is running and not all instances of test.exe.

解决方案

bool isRunning = Process.GetProcessesByName("test")
                .FirstOrDefault(p => p.MainModule.FileName.StartsWith(@"c:\loc1")) != default(Process);

这篇关于检查特定的exe文件运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆