Tracking Window with batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
One-Man-Army
Posts: 3
Joined: 03 Jun 2014 02:11

Tracking Window with batch

#1 Post by One-Man-Army » 03 Jun 2014 02:34

Hi there.
I'm looking for this for a few time, but I don't really know what to search for in this case.
I don't know if you know the problem with Firefox: If you start Firefox shortly after closing it, there will often be an error. Such like: Firefox is still running but doesn't react (Sorry i don't know the real english message).
Therefor I wrote a small .bat that only kills the task "firefox.exe" and then starts it again. At the moment this .bat is startet instead of the normal .exe. So that I don't have to open the taskmanager or the cmd to do it by myself. (yes I'm a bit lazy :))
The problem in this workaround is:
If I have an open window and I want to start a second, the .bat will be invoked. So all firefox windows will be closed before opening a new one.
Now I'm reflecting if there is any possibility, to look for the open windows. I think it would be enough to get the Windowname, because in every Firefox window at the end of the name is "Mozilla Firefox". And working with strings won't be the problem.
Is there any possibility for this? If you know a language where this will be easier, I'm open for everything :p
I know there are a few ways to get a second window, but it does no harm to get it easier and faster :)

Thanks in advance
Marius

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Tracking Window with batch

#2 Post by foxidrive » 03 Jun 2014 03:03

When you close Thunderbird or Firefox then the program has to unload and this can take a small amount of time.

Is that the issue you experience?

One-Man-Army
Posts: 3
Joined: 03 Jun 2014 02:11

Re: Tracking Window with batch

#3 Post by One-Man-Army » 03 Jun 2014 03:23

Yes. This is the problem. It's just annoying, that you'll have to wait, or kill the task. That's why I'm using a batch-script now. But the problem is, that it's used every time and not only if the problem occured.

Additionally I wouldn't say it's a small amount of time. I had it a few times, that I was afk for an hour or so and it was still running.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Tracking Window with batch

#4 Post by foxidrive » 03 Jun 2014 03:40

The lastest releases seem good here - back in the dark ages there was an issue like that.

You might like to start with a new profile and import your bookmarks and see if it still happens.

One-Man-Army
Posts: 3
Joined: 03 Jun 2014 02:11

Re: Tracking Window with batch

#5 Post by One-Man-Army » 03 Jun 2014 04:29

Ah ok. Didn't know that there was a fix for this.
But it seems like i found a solution:
The error sais that firefox is not responding. So the tasklist command can help. I just read the out of the tasklist by an for-loop. And by using an if I look if there is a token named "firefox.exe".
This way everything works: I can open the window anyway if there is a open task. If another window is open, a second one will be opened. So it's like I wanted :)
If someone has the same problem, this is my script:

Code: Select all

echo off

for /f "tokens=1" %%i in ('TASKLIST /FI "STATUS eq not responding"') do if %%i==firefox.exe ( taskkill /F /IM %%i )

start firefox.exe


This way I didn't need to track if there is an open window of firefox.

Thx Foxidrive

Best Regards Marius

Post Reply