Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent multiple instances of an Exe 1

Status
Not open for further replies.

djsiders

Programmer
Mar 6, 2002
76
US
How can you prevent a VB exe file from being launched more than once at any given time. For example, I double click test.exe to launch the program. Until I quit the test.exe program I do not want to allow the program to be started again. Once I exit, re-starting one instance is fine (actually necessary). I really need this to happen as soon as the program is started, possibly before the first form even appears.

Any help is appreciated.
 
You might try using the App.PrevInstance property.

If App.PrevInstance = True Then
Unload Me
End If Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Worked great! Guess I better look into the App object a little more & see what else I've been missing. Since I am starting my program from sub Main in a module, I revised the Unload to an End, but that was it. Here's how I tested it:

If App.PrevInstance = True Then
MsgBox "It worked", vbOKOnly, "Tek-Tips Rocks"
End
End If


Another star for CC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top