BATCH file for check and start

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ROBGIU1960
Posts: 2
Joined: 24 Jan 2021 07:04

BATCH file for check and start

#1 Post by ROBGIU1960 » 24 Jan 2021 07:08

I have to create a batch file that before running a program check that the same is not already running (warning if it is).

Otherwise it can start the program.

The program can be found in: C: \ Program files (x86) \ Artel \ arca.exe

Please you create a batch file for me ?

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: BATCH file for check and start

#2 Post by aGerman » 24 Jan 2021 07:22

Give that a go:

Code: Select all

@echo off &setlocal
tasklist /nh /fo csv /fi "imagename eq arca.exe"|>nul find """arca.exe"""
if errorlevel 1 (
  start "" "C:\Program Files (x86)\Artel\arca.exe"
  goto :eof
)

echo Program already running.
pause
Steffen

ROBGIU1960
Posts: 2
Joined: 24 Jan 2021 07:04

Re: BATCH file for check and start

#3 Post by ROBGIU1960 » 24 Jan 2021 07:44

thanks but the file always opens the program even if it is already running

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: BATCH file for check and start

#4 Post by aGerman » 24 Jan 2021 08:32

Might be that arca.exe is only a launcher which terminates as soon as the actual application is running. Try to figure out which process(es) indicate the running program. You may find them in the details tab of the task manager.

Steffen

Post Reply