473,408 Members | 1,762 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,408 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 3897
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.