Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Preventing multiple instances of a VB EXE from running?

I have a VB app that is delivered in the form of an EXE file.  I must prevent the user from running multiple instances of this program.  How do I do this?
0
david749
Asked:
david749
  • 3
1 Solution
 
beckinghCommented:
If App.PrevInstance = True Then
        MsgBox "There are two instances of the application running.  Please click OK, wait 10 seconds, and restart the application.  If the problem persists contact your System Administrator.", vbOKOnly, csMsgBoxTitle
        GoTo exitsub
    End If
0
 
beckinghCommented:
Obviously only the "If App.PrevInstance = True Then" part is relevant :)
0
 
beckinghCommented:
Here's a nice link to a way of launching the app that is already running.

http://vbcode.com/asp/showsn.asp?theID=574
0
 
Richie_SimonettiIT OperationsCommented:
One way to do it is adding a module to your project, create a sub Main procedure and:

Sub Main
    If app.previnstance then
       end
    else
       frmMain.show
    end if
End Sub

Don't forget to swith your start object to the sub main routine going to Project properties menu.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now