473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Only Allow One Instance Of EXE When Shell

I have a VB6 program that is going to Shell a VB.Net program to run. I want
the VB.Net program to only run once, so it if is not running and it is
Shelled, the program runs; if it is already running and it is Shelled, then
I wish the program to become visible. I do have to use the Shell process
since I do not have control over the VB6 program, other than what parameters
are sent to the Shell. Any ideas on how this can be accomplished?

Thank You,
Derek
Jul 19 '05 #1
2 4900
Hello,

"Derek Hart" <dm****@gte.net> schrieb:
I have a VB6 program that is going to Shell a VB.Net
program to run. I want the VB.Net program to only run
once, so it if is not running and it is Shelled, the program
runs; if it is already running and it is Shelled, then I
wish the program to become visible. I do have to
use the Shell process since I do not have control over the
VB6 program, other than what parameters are sent to the
Shell. Any ideas on how this can be accomplished?


In the VB.NET application:

\\\
Imports System.Threading
..
..
..
Dim m As Mutex = _
New Mutex(False, "{11C92606-65D9-4df2-9AEA-B6A4DA91BCE2}")
If m.WaitOne(10, False) Then
Application.Run(New Form1())
m.ReleaseMutex()
Else
MessageBox.Show("Application already running!")
End If
///

You can use 'AppActivate' to activate the other instance.

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Jul 19 '05 #2
Got this from a previous posting:

Just add that piece of code (here in C#) in your main method (you need to
include the System.Diagnostic namespace) :
Process currentProcess = Process.GetCurrentProcess();

Process [] allProcesses =
Process.GetProcessesByName(currentProcess.ProcessN ame);
if (allProcesses.Length > 1)

{

MessageBox.Show(currentProcess.ProcessName + " is already running !",
currentProcess.ProcessName, MessageBoxButtons.OK, MessageBoxIcon.Error);

}

else

{

//do your stuff here

}

"Derek Hart" <dm****@gte.net> wrote in message
news:eL**************@tk2msftngp13.phx.gbl...
I have a VB6 program that is going to Shell a VB.Net program to run. I want the VB.Net program to only run once, so it if is not running and it is
Shelled, the program runs; if it is already running and it is Shelled, then I wish the program to become visible. I do have to use the Shell process
since I do not have control over the VB6 program, other than what parameters are sent to the Shell. Any ideas on how this can be accomplished?

Thank You,
Derek

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
5
by: hikums | last post by:
How are multiple instances monitored? For example, there are 30 instances running on a AIX BOX running DB2 V8, is ps -ef |grep "inst" the best way to see if the instance is running, where instanes...
4
by: Andrew Chanter | last post by:
I have a VB app that has a routine that runs macros in a (password protected) Access 97 db. (I have attached the code below.) Most of these macros end up opening a form in the Access db for the...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
3
by: Derek Hart | last post by:
I have a VB6 program that is going to Shell a VB.Net program to run. I want the VB.Net program to only run once, so it if is not running and it is Shelled, the program runs; if it is already...
8
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
0
by: midlothian | last post by:
I have some long Excel routines that I would like to run from my database in a hidden, second instance of the same Access db. The macro I pass to the shell command to open the second instance...
11
by: Hari Sekhon | last post by:
I have written a script and I would like to ensure that the script is never run more than once at any given time. What is the best way of testing and exiting if there is another version of this...
206
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.