1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

ms dos batch file

Discussion in 'Software Development' started by markde101, Oct 9, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. markde101

    markde101 Thread Starter

    Joined:
    Oct 9, 2008
    Messages:
    9
    Hi

    i am trying to write a batch file... which looks at my active processors ever 5 minutes or so, if the application i choose is not running, the batch file should execute it automatically.

    If the app is running it should not run it

    Please assist
     
  2. devil_himself

    devil_himself

    Joined:
    Apr 7, 2007
    Messages:
    4,910
    Welcome To TSG markde101

    not the best way to do in batch.

    Code:
    ::this batch will never quit.
    @echo off
    setlocal
     
    :: Define operating environment
    set app=notepad.exe
    set Wait=300
     
    :loop
    ::Verify Instance Running
    tasklist |find /i "%app%" >nul
    if not errorlevel 1 echo %app% is running
    if errorlevel 1 start "" "%app%"
     
    echo Monitoring: %app%
    echo waiting:    %Wait% seconds
     
    :wait
    ping -n %Wait% localhost >nul
    goto :loop
    
    you can simply write a script which checks if the app is running , if not running then start it . then use scheduled task to run the script every 5 min.
     
  3. markde101

    markde101 Thread Starter

    Joined:
    Oct 9, 2008
    Messages:
    9
    HI Devil himself

    thanks for the speedy and spot on response...worked perfectly.Just need to get it to run in silent mode...then this baby is good to go.

    Thanks again
     
  4. markde101

    markde101 Thread Starter

    Joined:
    Oct 9, 2008
    Messages:
    9
    Hi Devil _himself

    Sorry for the super delayed response

    Just thought id let you know...the script you gave me works perfectly
    Thanks very much for your assistance
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/757547

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice