By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,198 Members | 1,698 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,198 IT Pros & Developers. It's quick & easy.

Check if program is running

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.