vb.net - Killing Two different Processes With VB -


i trying figure out how kill 2 processes @ same time have managed 1 work when opened other wont close.

  sub block()     each item process in process.getprocesses         if item.processname = "taskmgr" , item.processname = "cmd"             item.kill()         end if     next end sub 

as noted @noodles , @zaggler logic wrong on line;

  if item.processname = "taskmgr" , item.processname = "cmd" 

this line asks if process name "taskmgr" , if same process name "cmd". since these 2 strings aren't same "taskmgr" /= "cmd" if clause never true. suggest this;

sub block()   each item process in process.getprocesses     if item.processname = "taskmgr"         item.kill()     elseif item.processname = "cmd"         item.kill()     end if   next end sub 

or optionally if plan close many processes;

'declare @ form loading or elsewhere dim proclist new list (of string) proclist.add("taskmgr") proclist.add("cmd") proclist.add("...")  sub block()   each item process in process.getprocesses     if proclist.contains(item.processname)          item.kill()     end if   next end sub 

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -