I had need to use this tool today and found to my dismay it wouldn't run under 64 bit Windows (7 Pro), so I quickly bashed out an alternate:
(defun _KillProcess ( process_name / @try shell filename handle )
;; Written by Michael Puckett, 2014
(defun @try ( try_statement ) ;; dumbed down version of mp.lsp: _Try
(vl-catch-all-apply
(function
(lambda ( )
(eval try_statement)
)
)
)
)
(vl-load-com)
(setq
shell (vlax-create-object "Shell.Application")
filename (vl-filename-mktemp "kill.vbs")
handle (open filename "w")
)
(foreach x
(list
(strcat
"Set wmiService = GetObject(\"winmgmts:"
"{impersonationLevel=impersonate}!\\\\"
".\\root\\cimv2\")"
)
(strcat
"Set processList = wmiService.ExecQuery"
"(\"Select * from Win32_Process Where Name = '"
process_name
"'\")"
)
"For Each process in processList"
" process.Terminate()"
"Next"
"Set processList = Nothing"
"Set wmiService = Nothing"
)
(princ (strcat x "\n") handle)
)
(close handle)
(@try '(vlax-invoke shell 'ShellExecute "cscript.exe" filename "" "runas" 0))
(@try '(vlax-release-object shell))
;; It's tempting to delete the temp vbs file we created above
;; but due to asynchronous execution of the shell execution
;; relative to the execution of this lisp function it tends to
;; terminate the shell execution prematurely (subtitle: we finish
;; before it does), so we'll just have to live with the litter
;; we've generated.
(princ)
)
Example:
(_KillProcess "notepad.exe")
FWIW ... Cheers.