I'm using VB.Net 2003
I have code - it works great - to kill a process(s) if they are running.
----
Dim myProcesses() As Process 'Funny - withouth the () in the
myProcesses it does not work
Dim myProcess As Process
myProcesses = Process.GetProcessesByName(Trim(TextBox1.Text))
For Each myProcess In myProcesses
myProcess.Kill()
Next
Close() 'Program stops running after it is run.
----
The user has a program that runs, but when the program loads, sometimes it
loads in the
"Processes" tab, but not in the Application tab ( of the Windows Task
Manager ). This program
loads up some files associated with it, and actaully Locks these files until
its killed. This program also
only allows you to run one instance of it.
So what I would like to do, is Get all the processes ( see above code ), and
see if there is an Application
running associated with it.
If there is not, then kill that process.
If there is an Application, then just set focus to it.
I cannot find help on this on the net.
Can someone point me in the right direction please.
Thanks,
Miro 4 1602
The reason that you need the () after myprocesses is that it is used as an
array when getting all the names of the processes, i.e., GetProcessesByName
returns an array all processes with the name passed to the method.
--
Dennis in Houston
"Miro" wrote:
I'm using VB.Net 2003
I have code - it works great - to kill a process(s) if they are running.
----
Dim myProcesses() As Process 'Funny - withouth the () in the
myProcesses it does not work
Dim myProcess As Process
myProcesses = Process.GetProcessesByName(Trim(TextBox1.Text))
For Each myProcess In myProcesses
myProcess.Kill()
Next
Close() 'Program stops running after it is run.
----
The user has a program that runs, but when the program loads, sometimes it
loads in the
"Processes" tab, but not in the Application tab ( of the Windows Task
Manager ). This program
loads up some files associated with it, and actaully Locks these files until
its killed. This program also
only allows you to run one instance of it.
So what I would like to do, is Get all the processes ( see above code ), and
see if there is an Application
running associated with it.
If there is not, then kill that process.
If there is an Application, then just set focus to it.
I cannot find help on this on the net.
Can someone point me in the right direction please.
Thanks,
Miro
Thanks that answers that little if part. I was gonna search for that later.
I originally got this example from a website ( im still learning vb ) and it
didnt have it.
So i couldnt figure out why i needed it and they didnt.
Does anyone know how to do the App and process thing?
Thanks again Dennis.
Miro
"Dennis" <De****@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
The reason that you need the () after myprocesses is that it is used as an
array when getting all the names of the processes, i.e.,
GetProcessesByName
returns an array all processes with the name passed to the method.
--
Dennis in Houston
"Miro" wrote:
>I'm using VB.Net 2003
I have code - it works great - to kill a process(s) if they are running. ---- Dim myProcesses() As Process 'Funny - withouth the () in the myProcesses it does not work Dim myProcess As Process
myProcesses = Process.GetProcessesByName(Trim(TextBox1.Text)) For Each myProcess In myProcesses myProcess.Kill() Next
Close() 'Program stops running after it is run. ----
The user has a program that runs, but when the program loads, sometimes it loads in the "Processes" tab, but not in the Application tab ( of the Windows Task Manager ). This program loads up some files associated with it, and actaully Locks these files until its killed. This program also only allows you to run one instance of it.
So what I would like to do, is Get all the processes ( see above code ), and see if there is an Application running associated with it. If there is not, then kill that process. If there is an Application, then just set focus to it.
I cannot find help on this on the net. Can someone point me in the right direction please.
Thanks,
Miro
Also one more question i just ran accross this.
What is the difference between:
Dim myProcesses() As Process
and
Dim myProcesses() As System.Diagnostics.Process
I find the System.Diagnostics works better because then i can do this:
If myProcesses.Length 0 Then
If I just declare it as a Process I cannot get the length of it.
"Miro" <mi******@golden.netwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
Thanks that answers that little if part. I was gonna search for that
later.
I originally got this example from a website ( im still learning vb ) and
it didnt have it.
So i couldnt figure out why i needed it and they didnt.
Does anyone know how to do the App and process thing?
Thanks again Dennis.
Miro
"Dennis" <De****@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
>The reason that you need the () after myprocesses is that it is used as an array when getting all the names of the processes, i.e., GetProcessesByName returns an array all processes with the name passed to the method.
-- Dennis in Houston
"Miro" wrote:
>>I'm using VB.Net 2003
I have code - it works great - to kill a process(s) if they are running. ---- Dim myProcesses() As Process 'Funny - withouth the () in the myProcesses it does not work Dim myProcess As Process
myProcesses = Process.GetProcessesByName(Trim(TextBox1.Text)) For Each myProcess In myProcesses myProcess.Kill() Next
Close() 'Program stops running after it is run. ----
The user has a program that runs, but when the program loads, sometimes it loads in the "Processes" tab, but not in the Application tab ( of the Windows Task Manager ). This program loads up some files associated with it, and actaully Locks these files until its killed. This program also only allows you to run one instance of it.
So what I would like to do, is Get all the processes ( see above code ), and see if there is an Application running associated with it. If there is not, then kill that process. If there is an Application, then just set focus to it.
I cannot find help on this on the net. Can someone point me in the right direction please.
Thanks,
Miro
Both of the below work. The System.Diagnostics is just the namespace which
contains the Process Class and you are just using the fully qualifiec Class
Type Name when you dimension Process using the System.Diagnostics.
Dim myprocesses() As Process
If myprocesses.Length 0 Then
'do something
End If
Dim myProcesses() As System.Diagnostics.Process
If myprocesses.Length 0 Then
'do something
End If
--
Dennis in Houston
"Miro" wrote:
Also one more question i just ran accross this.
What is the difference between:
Dim myProcesses() As Process
and
Dim myProcesses() As System.Diagnostics.Process
I find the System.Diagnostics works better because then i can do this:
If myProcesses.Length 0 Then
If I just declare it as a Process I cannot get the length of it.
"Miro" <mi******@golden.netwrote in message
news:OU**************@TK2MSFTNGP06.phx.gbl...
Thanks that answers that little if part. I was gonna search for that
later.
I originally got this example from a website ( im still learning vb ) and
it didnt have it.
So i couldnt figure out why i needed it and they didnt.
Does anyone know how to do the App and process thing?
Thanks again Dennis.
Miro
"Dennis" <De****@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
The reason that you need the () after myprocesses is that it is used as
an
array when getting all the names of the processes, i.e.,
GetProcessesByName
returns an array all processes with the name passed to the method.
--
Dennis in Houston
"Miro" wrote:
I'm using VB.Net 2003
I have code - it works great - to kill a process(s) if they are running. ---- Dim myProcesses() As Process 'Funny - withouth the () in the myProcesses it does not work Dim myProcess As Process
myProcesses = Process.GetProcessesByName(Trim(TextBox1.Text)) For Each myProcess In myProcesses myProcess.Kill() Next
Close() 'Program stops running after it is run. ----
The user has a program that runs, but when the program loads, sometimes it loads in the "Processes" tab, but not in the Application tab ( of the Windows Task Manager ). This program loads up some files associated with it, and actaully Locks these files until its killed. This program also only allows you to run one instance of it.
So what I would like to do, is Get all the processes ( see above code ), and see if there is an Application running associated with it. If there is not, then kill that process. If there is an Application, then just set focus to it.
I cannot find help on this on the net. Can someone point me in the right direction please.
Thanks,
Miro
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jacek Popławski |
last post by:
Hello.
I am going to write python script which will read python command from
socket, run it and return some values back to socket.
My problem is, that I need some timeout. I need to say for...
|
by: Dakkar |
last post by:
How can i control my program when someone kill it's process from the
taskmanager
my dispose script is working well if i close the program manually but
if i kill it from taskmanager its not working...
|
by: Shruti A via .NET 247 |
last post by:
hello group
I have recently started working on .Net platform.
I am facing one problem in killing and starting process from my aspx page.
I am able to kill and start the same process from vb.net...
|
by: kunal.kewalramani |
last post by:
I'm opening an Excel file using ASP.NET, but Excel process remains it is not killed, I tried killing it by using Quit() that is also not working, if anybody have any solution for this please help me...
|
by: shiry |
last post by:
Hi,
I need to do some important cleanup before my console application
exists. I used the console ctrl event. This is working well and it
fires for all cases, including the CTRL_CLOSE_EVENT (if I...
| |
by: laststubborn |
last post by:
Hi everybody,
We have a very large database and high transaction volume. Time to time
these transactions are locking each other and decrease the performance
of the database. Is there any way...
|
by: Rain |
last post by:
Does anyone know how i can kill a process using C#? im developing an asp.net
web application using C# and the asp.net process doesnt die even if the
application has already exited. So i need to...
|
by: tony.newsgrps |
last post by:
Hi there,
I'm trying to understand the impact of killing a process that owns a
system mutex (used to ensure there is only 1 instance of my program
running)
Here is my code pretty much:
try...
|
by: Thomas Nelson |
last post by:
Hi, I'd like to start a program, run it for a while, then terminate
it. I can do this on linux, but I'm new to working with windows.
Here's my script:
from subprocess import Popen
from time...
|
by: Roger Heathcote |
last post by:
sjdevnull@yahoo.com wrote:
<snip>
Fair point, but for sub processes that need to be in close contact with
the original app, or very small functions that you'd like 100s or 1000s
of it seems...
|
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...
| |
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,...
|
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: 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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |