Link to home
Start Free TrialLog in
Avatar of CalmSoul
CalmSoulFlag for United States of America

asked on

Killing Process Using Batch Script

I am using following command kill a process but its not working.

taskkill /f /im /t wowexec.exe
tskill wowexec.exe  /a /v
processes.png
Avatar of fhillyer1
fhillyer1

is your batch script being run as administrator?

i suggest you to open a cmd window then run your batch and see any echo displayed by the commands to see if there is a problem or a message displayed when you run it
The image name has to go immediately after the /im switch.  Try this.


taskkill /f /t /im wowexec.exe

Open in new window

Avatar of CalmSoul

ASKER

No is its not working Shift-3 I am running script as administrator
there is a space in front of process name... I am sure that is causing an issue.
Avatar of Bill Prew
You might try this, including the space in front of the taskname.       

taskkill /f /t /im " wowexec.exe"

~bp
still doesn't work.
It could be that it isn't actually a space in front of the wowexec, but some other non displayable character.  Why not get it's process id and kill it by that?

~bp
SOLUTION
Avatar of Joseph Daly
Joseph Daly
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No need for the piping. WMIC has the ability to do this natively

wmic process where name='notepad.exe' call terminate

and on a remote machine

wmic /node:{computername} process where name='notepad.exe' call terminate
Try this:

for /f "tokens=2" %%a in ('tasklist ^| findstr wowexec.exe') do taskkill /f /t /pid %%a

~bp
What error are you getting?
Didn't work guys.. I run the batch file no error comes up. Screen blinks and go away.
There is no PID accosciated to process.
Have you tried the command I mentioned

wmic process where name='wowexec.exe' call terminate
I think wowexec *may* be a 16 bit program (vague memory?), could it be running under ntvdm.exe?

~bp
So I think you want to kill ntvdm.exe, and it will take wowexec.exe with it...

~bp
Wowexec is a 16 bit process. If BP is right try the following

wmic process where name='ntvdm.exe' call terminate
Of course this should work too.

taskkill /f /t /im ntvdm.exe

~bp
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Still can't get it killed. Any other way guys?
Can you kill the process through the taskmgr gui? Does it stay eneded? If you are running a 16 bit application it will continue to restart.
I can right click and end process from gui.
i dont know how are you running your system but straight command line works i attached 2 pictures 1 having ntvdm.exe loaded because i opened a 16 bit application that launches it, in a command window
and on another command window i entered the taskkill command

on the second picture you will see that i pressed enter to kill the appl and it actually gave me the message that it worked well
and on the other command window it returned me to the prompt and on task manager no ntvdm.exe is found
1a.JPG
1b.JPG
can you provide us with a sample screenshot on how are you tyoing the command, showing us as well the ntvdm.exe and wowexec under it, also run the command i want to see whats the Echo on the DOS screen when you run the command.

please
if you can just provide the screen just like i sent it DOS CMD, TASK MGR