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

How to kill process?

P: n/a
How do I gracefully kill a process than restart it? The process Image Name
is known.

Thanks,
Brett
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Q
Hello Brett,

hopes this helps

Regards

Dim myProcesses() As Process
Dim myProcess As Process
Dim teller As Integer = 0
'' Returns array containing all instances of "Notepad".
myProcesses = Process.GetProcessesByName("Notepad")
For Each myProcess In myProcesses
myProcess.CloseMainWindow()
teller += 1
Next
If teller > 0 Then
MessageBox.Show("closed")
Else
MessageBox.Show("Nothing to be closed")
End If

' start notepad
myProcess.Start("notepad.exe")
"Brett" <no@spam.com> wrote in message
news:uL****************@TK2MSFTNGP10.phx.gbl...
How do I gracefully kill a process than restart it? The process Image Name is known.

Thanks,
Brett

Nov 21 '05 #2

P: n/a
Do you know the name of the app, or any word that will appear in the title
bar? If so, you can loop through processes until you find the one that
matches the info you know about the title bar.

Dim knowntext as String = "whatever I know in title bar"
Dim proc as Process
Dim processlist() as Process
processlist = Process.GetProcesses
For each proc in processlist
If InStr(proc.ProcessName.ToUpper, knowntext.ToUpper)
If Not proc.CloseMainWindow() Then proc.Kill()
End If

(the double attempt to shut it down is deliberate--the first time to be nice
about it, the second to just get rid of it)

Terp
"Brett" <no@spam.com> wrote in message
news:uL****************@TK2MSFTNGP10.phx.gbl...
How do I gracefully kill a process than restart it? The process Image Name is known.

Thanks,
Brett

Nov 21 '05 #3

P: n/a
This works good for Notepad. The problem is the program has no interface.
It's call FreePops, http://www.freepops.org/en/. I can start a new instance
of it but the code won't close it. It sits in the tray and I can only right
click it to get a menu with About and Exit. There isn't any title bar. I
see this in the taskmanager, "freepopsd.exe".

How do I close that?

Thanks,
Brett

"Q" <Q@nomail.be> wrote in message
news:eK****************@TK2MSFTNGP12.phx.gbl...
Hello Brett,

hopes this helps

Regards

Dim myProcesses() As Process
Dim myProcess As Process
Dim teller As Integer = 0
'' Returns array containing all instances of "Notepad".
myProcesses = Process.GetProcessesByName("Notepad")
For Each myProcess In myProcesses
myProcess.CloseMainWindow()
teller += 1
Next
If teller > 0 Then
MessageBox.Show("closed")
Else
MessageBox.Show("Nothing to be closed")
End If

' start notepad
myProcess.Start("notepad.exe")
"Brett" <no@spam.com> wrote in message
news:uL****************@TK2MSFTNGP10.phx.gbl...
How do I gracefully kill a process than restart it? The process Image

Name
is known.

Thanks,
Brett


Nov 21 '05 #4

P: n/a
Actually, I have to use myProcess.Kill() rather than close() or
closemainwindow() before it shuts the app down. This is what I wanted to
avoid.

Any suggestions?

Thanks,
Brett
"Brett" <no@spam.com> wrote in message
news:ub****************@TK2MSFTNGP09.phx.gbl...
This works good for Notepad. The problem is the program has no interface.
It's call FreePops, http://www.freepops.org/en/. I can start a new
instance of it but the code won't close it. It sits in the tray and I can
only right click it to get a menu with About and Exit. There isn't any
title bar. I see this in the taskmanager, "freepopsd.exe".

How do I close that?

Thanks,
Brett

"Q" <Q@nomail.be> wrote in message
news:eK****************@TK2MSFTNGP12.phx.gbl...
Hello Brett,

hopes this helps

Regards

Dim myProcesses() As Process
Dim myProcess As Process
Dim teller As Integer = 0
'' Returns array containing all instances of "Notepad".
myProcesses = Process.GetProcessesByName("Notepad")
For Each myProcess In myProcesses
myProcess.CloseMainWindow()
teller += 1
Next
If teller > 0 Then
MessageBox.Show("closed")
Else
MessageBox.Show("Nothing to be closed")
End If

' start notepad
myProcess.Start("notepad.exe")
"Brett" <no@spam.com> wrote in message
news:uL****************@TK2MSFTNGP10.phx.gbl...
How do I gracefully kill a process than restart it? The process Image

Name
is known.

Thanks,
Brett



Nov 21 '05 #5

P: n/a
BTW, I can right click on the program in the tray and select Exit to close
it.

Brett

"Brett" <no@spam.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Actually, I have to use myProcess.Kill() rather than close() or
closemainwindow() before it shuts the app down. This is what I wanted to
avoid.

Any suggestions?

Thanks,
Brett
"Brett" <no@spam.com> wrote in message
news:ub****************@TK2MSFTNGP09.phx.gbl...
This works good for Notepad. The problem is the program has no
interface. It's call FreePops, http://www.freepops.org/en/. I can start
a new instance of it but the code won't close it. It sits in the tray
and I can only right click it to get a menu with About and Exit. There
isn't any title bar. I see this in the taskmanager, "freepopsd.exe".

How do I close that?

Thanks,
Brett

"Q" <Q@nomail.be> wrote in message
news:eK****************@TK2MSFTNGP12.phx.gbl...
Hello Brett,

hopes this helps

Regards

Dim myProcesses() As Process
Dim myProcess As Process
Dim teller As Integer = 0
'' Returns array containing all instances of "Notepad".
myProcesses = Process.GetProcessesByName("Notepad")
For Each myProcess In myProcesses
myProcess.CloseMainWindow()
teller += 1
Next
If teller > 0 Then
MessageBox.Show("closed")
Else
MessageBox.Show("Nothing to be closed")
End If

' start notepad
myProcess.Start("notepad.exe")
"Brett" <no@spam.com> wrote in message
news:uL****************@TK2MSFTNGP10.phx.gbl...
How do I gracefully kill a process than restart it? The process Image
Name
is known.

Thanks,
Brett



Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.