PAMMIEO
asked on
KILL PROCESS BY TITLE OR CAPTION-URGENT 500 PTS
Hi Experts,
I need a code to kill a windows explorer window where caption/title = "Some Caption" or where url = "http:/..."
I've got this and it's working great and would like to continue using with modifications to look at caption or title:
For Each Process In GetObject("winmgmts:").Exe cQuery("se lect * from Win32_Process where Name='IEXPLORE.exe'")
Process.Terminate
Next
Pretty urgent. Thanks in advance.
I need a code to kill a windows explorer window where caption/title = "Some Caption" or where url = "http:/..."
I've got this and it's working great and would like to continue using with modifications to look at caption or title:
For Each Process In GetObject("winmgmts:").Exe
Process.Terminate
Next
Pretty urgent. Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, this is an Access VBA question.
PAMMIEO,
try the function i posted.
it will terminate internet explorer or window explorer with the strtitle passed to the function
try the function i posted.
it will terminate internet explorer or window explorer with the strtitle passed to the function
ASKER
okay, here's what i have now. I also set my references, but it's working at this point. The code is bypassing and not closing the window but continuing with the rest of the code in the Sub as if there is not an iexplorer window open with that title.
Dim shlShellWindows As New SHDocVw.ShellWindows
Dim expExplorer As SHDocVw.InternetExplorer
strTitle = "http://test.job.com/testagain/auto_add"
For Each expExplorer In shlShellWindows
If expExplorer.LocationName Like strTitle Then
expExplorer.Quit
' Exit Function
End If
Next
I change the expExplorer.LocationName = strTitle Then
to
expExplorer.LocationName LIKE strTitle Then
Dim shlShellWindows As New SHDocVw.ShellWindows
Dim expExplorer As SHDocVw.InternetExplorer
strTitle = "http://test.job.com/testagain/auto_add"
For Each expExplorer In shlShellWindows
If expExplorer.LocationName Like strTitle Then
expExplorer.Quit
' Exit Function
End If
Next
I change the expExplorer.LocationName = strTitle Then
to
expExplorer.LocationName LIKE strTitle Then
this post not for points.
I have a different solution, one that closes any window but cap's solution looks good for wot u want.
Slight amendment to what u have done (note, credit to Cap as its his solution)
change
If expExplorer.LocationName Like strTitle
to
If instr(1,expExplorer.Locati onName,str Title) > 0 then
I have a different solution, one that closes any window but cap's solution looks good for wot u want.
Slight amendment to what u have done (note, credit to Cap as its his solution)
change
If expExplorer.LocationName Like strTitle
to
If instr(1,expExplorer.Locati
actually, u may consider casing issues, so perhaps ensure strTitle always is lowercase and wrap expExplorer.LocationName with lcase
PAMMIEO,
a piece of advice in writing codes.
before doing any modification to the codes, test it first if it will work as written, then modify to suit your need.
1.
strTitle = "http://test.job.com/testagain/auto_add"
as indicated, you need to pass the the title not the url
open http://test.job.com/testagain/auto_add and look what it say on the title
copy the title and use it instead of the URL
2.
If expExplorer.LocationName Like strTitle Then
was written as
If expExplorer.LocationName = strTitle Then
the use of = and Like are not the same, so you cannot directly substitute { Like } with the = sign
try the codes first using the title
and post here what you want done...
a piece of advice in writing codes.
before doing any modification to the codes, test it first if it will work as written, then modify to suit your need.
1.
strTitle = "http://test.job.com/testagain/auto_add"
as indicated, you need to pass the the title not the url
open http://test.job.com/testagain/auto_add and look what it say on the title
copy the title and use it instead of the URL
2.
If expExplorer.LocationName Like strTitle Then
was written as
If expExplorer.LocationName = strTitle Then
the use of = and Like are not the same, so you cannot directly substitute { Like } with the = sign
try the codes first using the title
and post here what you want done...
ASKER
hey Rocki!!!
okay, let me try Capricon.
okay, let me try Capricon.
ASKER
Capricorn1,
I'm sending a URL Request which opens the explorer window. The title is the URL.
I'm sending a URL Request which opens the explorer window. The title is the URL.
ASKER
Capricorn. Neva neva neva mind. I'm having my guys add a title to the html. Then I'm sure your code will work. I'll let you know as soon as they've completed that part and I test.
ASKER
Rocki, the title will be constant; so, I think that will take care of the casing issue. I'll insert the title in the code. Tks.
if you want to use the URL
use
expExplorer.LocationURL
instead of
expExplorer.LocationName
use
expExplorer.LocationURL
instead of
expExplorer.LocationName
using the url
Function fCloseIE(strUrl As String)
On Error Resume Next
Dim shlShellWindows As New SHDocVw.ShellWindows
Dim expExplorer As SHDocVw.InternetExplorer
For Each expExplorer In shlShellWindows
If expExplorer.LocationURL = strURL Then
expExplorer.Quit
Exit Function
End If
Next
End Function
ASKER
The accepted worked. Thanks a mil.
How do Pammieo :) How ya doin!
Nice solution cap. The code snippet I have makes use of FindWindow, I guess overkill for this question
Nice solution cap. The code snippet I have makes use of FindWindow, I guess overkill for this question
Are you posting in the correct forum. This one is for Microsoft Access database questions.
Pete