DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Execute only if not running  (Read 8,216 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Execute only if not running
« on: September 23, 2014, 12:27 PM »
I would like to make a bat file to launch several applications, but only if the process is not running

By example :

start "" echo off
start "" /LOW "%programfiles%\FileZilla Server\FileZilla Server Interface.exe"
start "" /LOW "%programfiles%\FaxTalk Communicator\FTMain32.exe"
start "" "%userprofile%\Datos de programa\Microsoft\Internet Explorer\Quick Launch\Mostrar escritorio.scf"
start "" /LOW "%programfiles%\Quitometro\Quitometro.exe"
start "" /LOW "Y:\PORTABLES\Personaliza pc\DesktopDot\reddot.exe"

But If Quitometro.exe or reddot.exe are running previously don't launch , by example

Best Regards
:-*

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: Execute only if not running
« Reply #2 on: September 23, 2014, 01:12 PM »
Running to try Miles.
Best Regards
:P

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: Execute only if not running
« Reply #3 on: September 23, 2014, 02:31 PM »
:-[

How can i do for example the process Quitometro.exe

There are several scripts in the link and is difficult for me to understand.
Best Regards
:-*

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Execute only if not running
« Reply #4 on: September 23, 2014, 07:39 PM »
See the line that pipes from tasklist into the find command and the comment about ErrorLevel.

Basically tasklist gets the running programs and pipes it into find.  If the program title or whatever is not found it is not running.

If it doesn't have to be batch ahk Process command is probably easier.  Like
Process,Exist,notepad.exe ; sets ErrorLevel

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: Execute only if not running
« Reply #5 on: September 24, 2014, 01:40 AM »
if you want an AHK solution as Miles suggested, this snippet would be a start. win+a launches notepad if it is not running.

Code: (autohotkey)
notepadpath = c:\windows\notepad.exe

#a::
Process, Exist, notepad.exe ; see if notepad is running
{
If ! ErrorLevel
	{
	IfExist, % notepadpath
		Run,% notepadpath
	Return
	}
}

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Execute only if not running
« Reply #6 on: September 24, 2014, 10:24 AM »
See number 12 on the page I linked.  It explains that if the Find command finds only white space ( " " ) then the program is not running.  Change "imagename eq notepad.exe" so that your program's exe file is substituted for notepad.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: Execute only if not running
« Reply #7 on: September 24, 2014, 02:20 PM »
Running to try.
Best Regards
:-*

Original address: https://www.donationcoder.com/forum/index.php?topic=39042.0