473,388 Members | 986 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,388 software developers and data experts.

Check if program is running

How could I check if my app is running.

I would like to check if my app is running for specified user, because it is
used in Terminal Server.

I want the program to somehow check if another copy is running for the user,
and if so to display a warning message, them exit.

TIA
Nov 21 '05 #1
8 3894
Nikolay,

I don't know it in a Terminal Server this is the easiest one without, which
prevents however as well other programs with the same name to run.

\\\
Private mutCreated as Boolean
Private mut As New Threading.Mutex(True, "myProgram", mutCreated)
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not mutCreated Then Me.Close()
'etc
End Sub
///
I hope this helps?

Cor
Nov 21 '05 #2
Nikolay,

I don't know it in a Terminal Server this is the easiest one without, which
prevents however as well other programs with the same name to run.

\\\
Private mutCreated as Boolean
Private mut As New Threading.Mutex(True, "myProgram", mutCreated)
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not mutCreated Then Me.Close()
'etc
End Sub
///
I hope this helps?

Cor
Nov 21 '05 #3
the method with the mutex is ok
but don't work in Terminal Server, because when one user run the program,
others can't

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eJ**************@TK2MSFTNGP14.phx.gbl...
Nikolay,

I don't know it in a Terminal Server this is the easiest one without,
which prevents however as well other programs with the same name to run.

\\\
Private mutCreated as Boolean
Private mut As New Threading.Mutex(True, "myProgram", mutCreated)
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not mutCreated Then Me.Close()
'etc
End Sub
///
I hope this helps?

Cor

Nov 21 '05 #4
the method with the mutex is ok
but don't work in Terminal Server, because when one user run the program,
others can't

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eJ**************@TK2MSFTNGP14.phx.gbl...
Nikolay,

I don't know it in a Terminal Server this is the easiest one without,
which prevents however as well other programs with the same name to run.

\\\
Private mutCreated as Boolean
Private mut As New Threading.Mutex(True, "myProgram", mutCreated)
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not mutCreated Then Me.Close()
'etc
End Sub
///
I hope this helps?

Cor

Nov 21 '05 #5
Here's the routine I use for checking if another copy is currently
running. Not sure if this returns a false positive if another user on a
terminal server is running it though.

Function PrevInstance() As Boolean
If UBound( _
Diagnostics.Process.GetProcessesByName( _
Process.GetCurrentProcess.ProcessName)) > 0 Then
Return True
End
Else
Return False
End If
End Function

Hope this helps,
Brian Swanson

"Nikolay Petrov" <jo**************@mail.bg> wrote in message
news:jo**************@mail.bg:
How could I check if my app is running.

I would like to check if my app is running for specified user, because it
is
used in Terminal Server.

I want the program to somehow check if another copy is running for the
user,
and if so to display a warning message, them exit.

TIA


Nov 21 '05 #6
Here's the routine I use for checking if another copy is currently
running. Not sure if this returns a false positive if another user on a
terminal server is running it though.

Function PrevInstance() As Boolean
If UBound( _
Diagnostics.Process.GetProcessesByName( _
Process.GetCurrentProcess.ProcessName)) > 0 Then
Return True
End
Else
Return False
End If
End Function

Hope this helps,
Brian Swanson

"Nikolay Petrov" <jo**************@mail.bg> wrote in message
news:jo**************@mail.bg:
How could I check if my app is running.

I would like to check if my app is running for specified user, because it
is
used in Terminal Server.

I want the program to somehow check if another copy is running for the
user,
and if so to display a warning message, them exit.

TIA


Nov 21 '05 #7
Brian,

"Brian Swanson" <pu*******@gREMOVETHISmail.com> schrieb:
Here's the routine I use for checking if another copy is currently
running. Not sure if this returns a false positive if another user on a
terminal server is running it though.

Function PrevInstance() As Boolean
If UBound( _
Diagnostics.Process.GetProcessesByName( _
Process.GetCurrentProcess.ProcessName)) > 0 Then
Return True
End
Else
Return False
End If
End Function


Notice that process names are not necessarily unique, so there can be
different applications with the same process name.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8
Brian,

"Brian Swanson" <pu*******@gREMOVETHISmail.com> schrieb:
Here's the routine I use for checking if another copy is currently
running. Not sure if this returns a false positive if another user on a
terminal server is running it though.

Function PrevInstance() As Boolean
If UBound( _
Diagnostics.Process.GetProcessesByName( _
Process.GetCurrentProcess.ProcessName)) > 0 Then
Return True
End
Else
Return False
End If
End Function


Notice that process names are not necessarily unique, so there can be
different applications with the same process name.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #9

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

Similar topics

2
by: Amrik Singh | last post by:
HI folks can anyone help a newbie here. I would like to know how I can check if my software is already running. So that if the user click s on the shortcut to start the progam again it maximises...
3
by: Fabio Pliger | last post by:
Hi, is it possibile, in python, to check for an already running instance of an application? My problem is that, if my program i running and the user relaunch it, i don't want to open a new...
6
by: Pierre-Yves | last post by:
Hello, I would like to prevent my perl program to be executed several times simultaneously (if the program is already running, I would like to display a message like "another instance of this...
4
by: Nick Sinclair | last post by:
Hi all, I'm new to C. I have successfully written a small C program that acts as a "wrapper" around cgi scripts. These scripts perform admin tasks such as backing up etc. Obviously, The need...
3
by: Brian Henry | last post by:
I want to make a schedule of events to occur in a windows service (kinda like a scheduler) so the user can specify through an external interface to do a task at a certain time... like this 8pm -...
0
by: Nikolay Petrov | last post by:
How could I check if my app is running. I would like to check if my app is running for specified user, because it is used in Terminal Server. I want the program to somehow check if another...
12
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
0
by: Venky K Shankar | last post by:
On Sunday 20 July 2008 12:08:49 am Lamonte Harris wrote: you can execute OS system call. here i execute ps -ef and grep the required process name (or you can grep by pid on that particular...
12
by: Shadlan | last post by:
Hi. I need to know if a service is running on my server. Is there any PHP instruction that I can use to do this?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.