/* KILLPROG, Version 1.01 */ /* Kill process by its executable file name */ /* Written by Rob van der Woude */ /* http://www.robvanderwoude.com */ /* Check command line parameters */ parse upper arg exec"/"options exec = strip( exec ) options = strip( options ) if exec = "" then call Syntax exactmatch = 0 confirm = 1 if options <> "" then do if pos( "?", options ) > 0 then call Syntax if pos( "X", options ) = 0 & pos( "Y", options ) = 0 then call Syntax parse value options with option1"/"option2 option1 = strip( option1 ) option2 = strip( option2 ) if option1 = "X" | option2 = "X" then exactmatch = 1 if option1 = "Y" | option2 = "Y" then confirm = 0 end /* Initialize RexxUtil */ if RxFuncQuery( "SysLoadFuncs" ) <> 0 then do call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs" call SysLoadFuncs end /* Initialize Quercus System's RexxLib */ if RxFuncQuery( "RexxLibRegister" ) <> 0 then do call RxFuncAdd "RexxLibRegister", "rexxlib", "RexxLibRegister" call RexxLibRegister end pid.0 = DOSPIDLIST( pid, name, parent, session ) if pid.0 > 0 then do i = 1 to pid.0 if ( exactmatch = 0 & pos( exec, name.i ) > 0 ) | ( exactmatch = 1 & exec = name.i ) then do if confirm = 1 then do say "Process ID = "||pid.i say "Program name = "||name.i say "Parent = "||parent.i say "Session ID = "||session.i say say "Are you sure you want to kill this process?" call SysCurState "OFF" answer = translate( SysGetKey( "NOECHO" ) ) if answer <> "Y" then iterate end rc = DOSKILLPROCESS( pid.i, "P" ) if rc = 1 then do say "Successfully killed process "||pid.i end else do call beep 220, 240 say "Error trying to kill process "||pid.i end end end EXIT 0 Syntax: procedure say say "KILLPROG, Version 1.01" say "Kill a process by its executable name" say "Written by Rob van der Woude" say "http://www.robvanderwoude.com" say say "Usage: KILLPROG file_name.ext [ /Y ]" say say "filename.ext is the executable's file name" say say "With /Y specified, the program will not ask for confirmation" say say "WARNING: This is an extremely powerful program, that" say " has the potential to destroy your data!" say " Use entirely at your own risk!" say " Do not use unless you understand its function!" EXIT 9 return