1

I've written a batch file to close few applications. One of my application asks confirmation message and requires to click on 'Yes' to close it. Is there any command that close these kind of application via batch file?

@echo off
tasklist /fi "imagename eq program1.exe"
tasklist /fi "imagename eq program2.exe"
(
taskkill /f /im program1.exe /t
taskkill /f /im program2.exe /t
timeout /t 2
start "" "program3.bat"
timeout /t 20
start "" "program4.bat"
timeout /t 30
start "" "program1.exe"
timeout /t 2
start "" "program2.exe"
)
pause
foxidrive
  • 40,353
  • 10
  • 53
  • 68
user3327568
  • 11
  • 1
  • 3
  • What application asks for confirmation? – Nick Udell Apr 30 '14 at 12:47
  • when i click exit option it asks "Are you sure to want to exit?" at this point i need to click on yes to close it – user3327568 Apr 30 '14 at 12:54
  • I think you misunderstand me. I was asking which program you are trying to close that is asking whether you are sure you want to esit. However it seems that this info is unneeded judging by the answers below. – Nick Udell Apr 30 '14 at 12:55

3 Answers3

1

Type:

taskkill /f /im "process name"

It has been answered already here: Any way to write a Windows .bat file to kill processes?

Community
  • 1
  • 1
Krzysztof Borowy
  • 538
  • 1
  • 5
  • 21
0

Try using something like this:

Taskkill /im [name of program]

For more infomation have a look here: http://technet.microsoft.com/en-gb/library/bb491009.aspx

Use /f to force close the application.

Taskkill /f /im [name of program]
09stephenb
  • 9,358
  • 15
  • 53
  • 91
  • i am using the above mentioned command but it need user interaction. but i want it to close without user interaction. is there a way to do this? – user3327568 Apr 30 '14 at 12:41
  • Have you tried the bottom code. If so can you show us your batch file. – 09stephenb Apr 30 '14 at 12:46
  • @echo off tasklist /fi "imagename eq program1.exe" tasklist /fi "imagename eq program2.exe" ( taskkill /f /im program1.exe /t taskkill /f /im program2.exe /t timeout /t 2 start "" "program3.bat" timeout /t 20 start "" "program4.bat" timeout /t 30 start "" "program1.exe" timeout /t 2 start "" "program2.exe" ) pause – user3327568 Apr 30 '14 at 12:51
  • Try it with out the /t para. – 09stephenb Apr 30 '14 at 12:58
0

You can use a tool that presses the key for you - such as: SENDKEYS or the more reliable AutoIt.

foxidrive
  • 40,353
  • 10
  • 53
  • 68