Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • September 25, 2016, 10:44:04 PM
  • Proudly celebrating 10 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 2003 times)

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Execute only if not running
« on: September 23, 2014, 07:27:04 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,158
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: Execute only if not running
« Reply #1 on: September 23, 2014, 07:47:10 AM »

Contro

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

Contro

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #3 on: September 23, 2014, 09:31:03 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,158
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: Execute only if not running
« Reply #4 on: September 23, 2014, 02:39:43 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,258
    • View Profile
    • Coding Snacks by Lanux128
    • Read more about this member.
    • Donate to Member
Re: Execute only if not running
« Reply #5 on: September 23, 2014, 08:40:32 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,158
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: Execute only if not running
« Reply #6 on: September 24, 2014, 05:24:49 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

  • Participant
  • Joined in 2007
  • *
  • Posts: 2,564
    • View Profile
    • Donate to Member
Re: Execute only if not running
« Reply #7 on: September 24, 2014, 09:20:26 AM »
Running to try.
Best Regards
 :-*