Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Windows Process running

Posted on 2016-08-04
3
Medium Priority
?
99 Views
Last Modified: 2016-08-04
I have inherited a VB.Net Windows form app
It compiles fine
But it was set up so that a Windows Task Scheduler opens it every 15 minutes
Is there a way to see if an instance of the App is already running and if there is > 5 instances.... exit instead of running anything?
0
Comment
Question by:lrbrister
3 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 41742639
You can use code like this to find out if a process is running:
Public Function IsProcessRunning(name As String) As Boolean
    'here we're going to get a list of all running processes on
    'the computer
    For Each clsProcess As Process In Process.GetProcesses()
        If clsProcess.ProcessName.StartsWith(name) Then
            'process found so it's running so return true
            Return True
        End If
    Next
    'process not found, return false
    Return False
End Function

Open in new window

0
 
LVL 21

Expert Comment

by:Randy Poole
ID: 41742655
You can edit your project properties and on the application tab, check the 'Make single instance application' checkbox
0
 

Author Closing Comment

by:lrbrister
ID: 41742665
Eric
You had the best answer to my specific request > 5
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question