How do I get list of Process Names running, in VB.NET?

前端 未结 4 1520
轮回少年
轮回少年 2020-12-11 03:04

I am trying to find out if an instance of an application (not vb.net) is already running - because I will want to start it but I don\'t want to start it if it is already run

4条回答
  •  天涯浪人
    2020-12-11 04:01

    Just tried the answer posted of Reed Copesy and this seems to be changed, what worked for me is:

    Dim procExists as Boolean = Process.GetProcesses().Any(Function(p) p.ProcessName.Contains(processName))
    

    Also is possible to retrieve the array by name and check directly if is contained on the process array:

    Process.GetProcessesByName(processName).Length > 0
    

    Thanks!

提交回复
热议问题