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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

killing a windows process

Status
Not open for further replies.

erixire

Technical User
Jun 4, 2002
72
CA
Hi everybody,

Is it possible to "kill" a windows process if I know the name of that process? Is it possible to know it's PID that is displayed in the system manager?

Thanks for help.

 
If you are using UNIX you would type in kill -9 followed by a space then the process number. ps will give you the processes running
 
Excuse for the confusion, but "windows process", should be read "Microsoft Windows process".

Does anyone have an idea?
 
I've not done enough Windows-specific programming to know if you can kill another executing program given just its name. My best advise is to go to the Tcl'ers Wiki ( and check out the page "kill," Perhaps the information and links provided there will get you on the right track. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
I posted a solution based on this wiki post and
the freely available nature of the kill and tlist utilities for windows. win2k comes with both. win9x
has them in the reskit directory of the cd-rom.

Here is some example code that you can perfect.


proc Lpick {{x "0"}} {
global arra
set lis [exec tlist]

 foreach el [split $lis "\n"] {
  puts $el
  regexp "\[0-9\]+ \[a-zA-Z\]+.exe" $el all  
  catch {set arra([incr x])   $all}
   }
}

proc KillIt {name} {
global arra
foreach poss [array name arra] {
set id [lindex [split $arra($poss) " "] 0]
set pname [lindex [split $arra($poss) " "] 1]
if {[string compare $name $pname] == 0} {
puts "Killing $name now."
exec kill $name
}
}
return
}

Lpick ; parray arra ;
foreach spec $argv {
KillIt $spec
}


time [list KillIt svchost.exe]
80000 microseconds per iteration
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top