If the application is runing or not

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
paulovale
Posts: 1
Joined: 03 Apr 2014 16:09

If the application is runing or not

#1 Post by paulovale » 03 Apr 2014 16:18

I need to create a bat file to go moving the files from one folder to another while an application is running

Is there any command that can use a bat file to verify that the application is running

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: If the application is runing or not

#2 Post by Dos_Probie » 03 Apr 2014 19:53

its call the program in use error and to close the application and try again

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

Re: If the application is runing or not

#3 Post by foxidrive » 04 Apr 2014 03:46

tasklist shows you if an application is running.

einstein1969
Expert
Posts: 976
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: If the application is runing or not

#4 Post by einstein1969 » 04 Apr 2014 07:26

try :

this code start a batch file when a program start, in this example firefox.exe:

Code: Select all

@echo off & setlocal EnableDelayedExpansion & set /a st=3 & for /L %%i in (1,0,1) do ( ping ::1 >nul 2>nul & tasklist | find "firefox.exe" >nul && set /a "st=(st*2+1)&3" || set /a "st=(st*2)&3" & if !st! equ 1 call C:\file.bat )


If you want that start even the program is alreay active then change "set /a st=3" with "set /a st=0"

einstein1969

Post Reply