3

I have two batch file one is always running (listerner.bat) but it is visible,the other one (mystop.bat)is to kill or stop my listener.bat and this two batch file are resides in this path C:\mydemo\mybatchfiles\,I am using windows 7

here is the code for mystop.bat

taskkill /F /FI "WINDOWTITLE eq Administrator: testlistener" /T

but when I run it,it will not terminate the running (listener.bat),There is no error but I have this message when I run it.

INFO: No tasks running with the specified criteria.

I appreciate someone can help me on this.I am new on this batch file command.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
jemz
  • 4,987
  • 18
  • 62
  • 102
  • I think this question belongs to Superuser rather than Stackoverflow – Shlublu Aug 02 '14 at 08:13
  • What does this have to do with computer science? – Ant P Aug 02 '14 at 08:14
  • What is the content of `testlistener` ? Does it change its title? is it really ran with admin permissions? What is the window title when you start the testlistener? – npocmaka Aug 02 '14 at 08:29
  • The title of the window in my test listener if i run is Administrator: testlistener – jemz Aug 02 '14 at 08:36
  • What OS are you using? Look at the output of `tasklist /v` to see the real window title if you are using a modern Windows. IIRC XP needs an extra space in the window title in some cases. – foxidrive Aug 02 '14 at 09:22
  • @foxidrive OP's using win7 it's mentioned in the question. after running a batch file that contains `@title Administrator: testlistener pause` which means it changes the window title to `Administrator: testlistener` and running the mentioned kill command it worked without any problems. So it might be the case that the window title it's really `Administrator: testlistener` – Scis Aug 02 '14 at 09:44
  • @Scis Thanks. Piping the output of `tasklist /v` into a text file will let jemz view it in a hex editor/viewer and see if any extra spaces or characters are in the Window title. Note that the spelling above is `listerner.bat` with an extra `r`. – foxidrive Aug 02 '14 at 10:27
  • @foxidrive Oh now I see, hehe maybe a typo is to blame – Scis Aug 02 '14 at 10:32
  • it's typo in my post,but here in my code it's not – jemz Aug 02 '14 at 11:22
  • Do you have tried also `taskkill /F /FI "WINDOWTITLE eq testlistener" /T` without "Administrator: "? I'm not sure, but I think "Administrator:" is just an indication for the user that this process is executed with administrative privileges and does not really belong to window title from the task list point of view. All titles of console windows start with "Administrator: " if UAC is disabled although window title not explicitly set with this string. – Mofi Aug 02 '14 at 15:35

3 Answers3

4

I had the same problem. In my case it was that there were two spaces in the window title:

taskkill.exe /F /FI "WindowTitle eq Administrator:  TailingErrorLog"
                                                  ^^  
armandino
  • 17,625
  • 17
  • 69
  • 81
martski
  • 342
  • 1
  • 5
1

Taskkill considers the command currently executed by listener.bat as part of the title. So you need to add a wildcard "*".

taskkill /F /FI "WINDOWTITLE eq Administrator: testlistener *" /T
Ir Relevant
  • 963
  • 6
  • 12
0

Try terminating using Im switch ..

Taskkill /Im listener.bat /t /f

Although this is not computer science related question , thought I should help ...

mordecai
  • 71
  • 4