Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Preventing multiple instances of a VB EXE from running?

Posted on 2001-06-13
4
Medium Priority
?
259 Views
Last Modified: 2012-05-04
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
Comment
Question by:david749
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
beckingh earned 150 total points
ID: 6185837
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
 
LVL 4

Expert Comment

by:beckingh
ID: 6185844
Obviously only the "If App.PrevInstance = True Then" part is relevant :)
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6185858
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6187559
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 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