topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 6:38 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Execute only if not running  (Read 5156 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Execute only if not running
« on: September 23, 2014, 07:27 AM »
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
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #1 on: September 23, 2014, 07:47 AM »

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #2 on: September 23, 2014, 08:12 AM »
Running to try Miles.
Best Regards
 :P

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #3 on: September 23, 2014, 09:31 AM »
 :-[

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
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #4 on: September 23, 2014, 02: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
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #5 on: September 23, 2014, 08:40 PM »
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 [Select]
  1. notepadpath = c:\windows\notepad.exe
  2.  
  3. #a::
  4. Process, Exist, notepad.exe ; see if notepad is running
  5. {
  6.         {
  7.         IfExist, % notepadpath
  8.                 Run,% notepadpath
  9.         Return
  10.         }
  11. }

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #6 on: September 24, 2014, 05: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,940
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #7 on: September 24, 2014, 09:20 AM »
Running to try.
Best Regards
 :-*