471,624 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,624 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 3818
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Fabio Pliger | last post: by
6 posts views Thread by Pierre-Yves | last post: by
4 posts views Thread by Nick Sinclair | last post: by
3 posts views Thread by Brian Henry | last post: by
reply views Thread by Nikolay Petrov | last post: by
12 posts views Thread by tshad | last post: by
reply views Thread by leo001 | last post: by

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.