Prozesse starten und beenden mit TWAPI
23. April 2009 | 10:15:38
Nachfolgend ein kleines Beispiel, das die Verwendung der TWAPI (Tcl Windows API) Extension illustriert.
Es wird hier das Programm notepad.exe gestartet und nach 5s wieder (automatisch) beendet.
source twapi.tm
puts [info tclversion]
set cmd twapi::create_process
lappend cmd [file join $::env(windir) notepad.exe]
set e [catch $cmd result]
set pid [lindex $result 0]
if { [twapi::process_exists $pid] == 1 } {
puts "process running..."
}
puts "ended: $e, pid: $pid"
puts [twapi::get_process_path $pid]
puts [twapi::get_process_name $pid]
set chk 0
after 5000 {set ::chk 1}
vwait chk
catch { twapi::end_process $pid }

