Version 7 of Using Kill on Windows 98

Updated 2002-08-28 07:14:15

SO Oct 14, 2001

Armed with our newly found kill.exe and tlist.exe programs from MicroSoft: ftp://ftp.microsoft.com/services/technet/samples/ps/win98/reskit/diagnose/

we decided to put them to use in a little tk script:


 wm title . "Win98 Kill-PID"
 wm resizable . 0 1

 #A helper proc -used later with tlist.exe
 proc do_cmd { cmd args } {
        catch {
        set result [eval exec [auto_execok $cmd] $args]
        }
        return $result
 }

 #A procedure to call kill.exe - using a tk_messageBox to verify prior to kill
 proc kill_it {  } {
        global current
        regsub -nocase -all {[a-z\.]} $current "" result
        set check [tk_messageBox -title "Verify Kill Process" -type yesno -icon warning \
                -message "You are about to kill a running process:\n $current \nAre you sure?"]

        switch $check {
                        yes { catch { eval exec [auto_execok c:/kill.exe] $result }
                 }
                        no { return }
                }      
        set current {}
        .list delete 0 end
        refresh .list
 }

 #Gets the selected pid and description from the listbox
 proc get_index { w } {
        global current win_pid
        catch {
                set current [lindex $win_pid [$w curselection]]
        }
        .top.button configure -text $current
        return $current
 }

 #Get the pid list using tlist.exe - there must be a better way to do the formatting...
 proc refresh { w } {
        global win_pid current
        .list delete 0 end
        set win_pid { }
        set result [do_cmd c:/tlist.exe]
        set result [split $result -]
        set result [string trimleft $result]
        set result [lreplace $result 0 0]
        foreach index $result {
                lappend win_pid [string trimright -$index]
                }     
        #  win_pid [string trimright -$index]
        foreach index $win_pid {
                $w insert end $index
                }
        .top.label configure -text "There are [llength $win_pid] processes currently running."
        return $win_pid
 }

 #Build the GUI
 proc make_GUI { } {
        frame .top
        button .top.button -width 50 -relief groove  -textvariable current \
                -font system -command {kill_it }
        label .top.label
        listbox .list -height 10 -width 50 -yscrollcommand ".scrl set" \
                -bg white -font system
        scrollbar .scrl -command ".list yview"
        pack .top
        pack .top.button
        pack .top.label
        pack .scrl -side right -fill y
        pack .list -side left -expand 1 -fill y
        bind .list <ButtonRelease-1> { get_index %W }
 }


 proc main { } {
        make_GUI
        refresh .list
 }

 main

I probably should have added a proc to keep the list current, but is it *REALLY* late, maybe tommorrow...

Is this sort of like the Windows ME/Windows NT Task Manager?

I suppose it is, there is a task manager on win 9x also

My apologies to anyone who has copied the script and had problems. It appears to have gotten mangled somehow over the weekend. It is okay now..