user875139
user875139

Reputation: 1621

How do you close a program as soon as you open it using a batch file?

I am trying to close firefox as soon as I open it, and then reopen it again in a batch file. This is what i have below:

@ECHO off
"C:\Program Files\Mozilla Firefox\firefox.exe"
sleep 10
taskkill /F/IM "C:\Program Files\Mozilla Firefox\firefox.exe"
sleep 10
"C:\Program Files\Mozilla Firefox\firefox.exe"

However it doesnt work, it just opens firefox and never closes it.

The system I am trying to get this to work on is Windows 7 Home Premium 64bit. I don't know if that makes much of a difference.

Any help on this will be greatly appreciated. Thanks.

Upvotes: 1

Views: 2073

Answers (1)

Sashenka
Sashenka

Reputation: 246

Taskkill is used to kill the process.

Try

taskkill /F/IM firefox.exe

Here is the documentation from MSDN

http://technet.microsoft.com/en-us/library/bb491009.aspx

Upvotes: 2

Related Questions