Check if a process is already running

Posted on 2007-10-17
Last Modified: 2012-06-22
I would like to use a simple DOS batch file to check if an app (process) is already running and if so, exit.  If it is not running, I'd like to start the app.  It would run on a Windows XP machine.  I'm thinking tlist.exe is the solution, but don't know how to apply it.

Question by:SophiG
    1 Comment
    LVL 67

    Accepted Solution

    Two of several possible solutions:

    - Build-in tools:
    tasklist  /fi "imagename eq taskmg.exe" 2>nul | findstr .exe  >nul && echo is running

    - pslist from
    pslist taskmgr.exe 2>nul >nul && echo is running

    && does exexute only if errorlevel is 0 (success).
    || executes when failed.

    Both ways, you can start your program with one single line.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
    YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT ( The crux of this batch f…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now