I need to terminate a software every time it is done transcoding a movie file. To automate this I made a small batch script. Therein I tried to use taskkill like this:

taskkill /im taskname.exe /t /f

But I always get the following error message: ERROR: The process with PID 6708 could not be terminated. Reason: There is no running instance of the task.

I also tried to start the cmd window as administrator and I also tried PowerShell. But when I do tasklist afterwards, it still shows the task.

Funny thing is that the task gets instantly terminated when I right-click on it in the task manager and end task. Which command does the "end task" call in the task manager? Something I can use to automate in a batch file?

| improve this question | | | | |
  • I don't know, but does tasklist list it? tasklist >file. – barlop May 18 '15 at 10:15
  • Yes tasklist shows it. – schmiddl May 18 '15 at 10:18
  • 1
    and I guess other programs close fine. Have you considered 3rd party command line apps? eg maybe nircmd.exe closeprocess theprocess.exe – barlop May 18 '15 at 10:30
  • 1
    Thats exactly what I was looking for! nircmd did the job. Thanks a lot! If you want you can post this as the answer: nircmd.exe killprocess processname – schmiddl May 18 '15 at 10:57
  • Yes, tried admin prompt and PowerShell admin prompt. I think this is a bug of the software I was trying to close, not something Windows did wrong. It is the command line version of easyDCP JPEG 2000 Standalone Transcoder. And it does not close itself after transcoding movies that come from ffmpeg. – schmiddl May 19 '15 at 4:36

As suggested by barlop the third party command line app nircmd.exe did the job!

nircmd.exe killprocess processname
| improve this answer | | | | |
  • Mark this as your answer then. – paradroid May 19 '15 at 1:24
  • Oh, okay. I don't remember having that restriction. – paradroid May 19 '15 at 4:35
  • Yeah, maybe this restriction will go away once I have posted more on superuser. – schmiddl May 19 '15 at 12:38
  • I doubt the restriction ever goes away 'cos i'm currently on > 9000 rep and still have that restriction! @paradroid maybe you also have the restriction but just haven't tried answering your own question much – barlop May 19 '15 at 15:28
  • @barlop Possibly; but it is possible to answer your own question at the same time as posting the question. – paradroid May 19 '15 at 16:35

If you cannot kill it by name, but have Process ID, you can try to kill it by PID:

for /f "delims== tokens=2" %%i in ('WMIC process where "Name='process.exe'" get ProcessId /value') do set pid=%%i 
echo Going to kill PID: %pid%
taskkill.exe /PID %pid%
| improve this answer | | | | |
  • Accessing the process by name or pid does not change anything. The error remains with taskkill. – schmiddl May 18 '15 at 11:44
  • What is the name of software You're trying to kill – kentzversky May 18 '15 at 12:38
  • Command line version of easyDCP JPEG 2000 Standalone Transcoder 1.0. It does not close itself after transcoding movies made with ffmpeg. – schmiddl May 19 '15 at 4:31
  • Checked their cmd manuals - not much there. As I know such kind of problem is common when executable is relaunched by some module. Why do you need to kill it, if software is designed to be persistent in memory. – kentzversky May 19 '15 at 12:11
  • Yes, there is a separate modul for the command line version. I spoke at length with their support and it was not supposed to be persistent. There is even a flag in the CLI version to turn persistence off. I have automated a few things with batch files. For the batch to continue, the software needs to be closed. But even with persistence off, it does not close sometimes. The Standalone Transcoder comes packaged with the easyDCP Creator+. They offer a trial version. But I don't think they offer a trial for my older version anymore. – schmiddl May 19 '15 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.