Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Kill a process

Status
Not open for further replies.

Denster

Programmer
Apr 9, 2001
198
GB
I'm using a web browser control to view PDF documents with acrobat reader. It is an old program working fine until installing acrobat 7. Now I cant do anything with the document because it seems like the reader is still open. I'm hoping it will be a simple matter of killing the adobe reader process but not sure how to do this. Does anyone know the syntax to do this.
 
This has been discussed many times in the past. Do a search for terminate process or kill process in the forms.

Besides that there is also an easy method. Use taskkill.exe or tskill.exe present in Windows XP.

See the following function.
___
[tt]
Sub KillProc(ImageName As String, Optional Force As Boolean)
If Force Then
Shell "taskkill /f /im " & ImageName, vbHide
Else
Shell "taskkill /im " & ImageName, vbHide
End If
End Sub[/tt]
___

You can call it like this: [tt]KillProc "calc.exe"[/tt]

taskkill.exe has a wide variety of options; like killing the process using its PID. See its command line help.
 
OK this works fine when I step through the code, but running the prog throws up a runtime error.
To get round I'v put a timer in and set it to half a second and it slows it down enough to work - DoEvents doesnt work!.

Not the prettiest solution but happy.

Thanks for the initial code!.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top