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
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)
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".
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.