Inno Setup. Detect if an EXE is running

Posted on 2008-11-07
Last Modified: 2012-05-05
I have a pretty simple Inno  setup script.   It installs some Exe's and Dll's  on a client PC.  I  want to check if 2 exe's are running  before the installation  proceeds  so I can notify the user to manually shut them before continuing.  I do not want to proceed and use the restartreplace flag.

I think I can add it to the CurStepChanged procedure but I can  find no function in Inno like   IsApplicationRunning(test.exe)...

Help please....
Question by:SarusSystems
    LVL 29

    Accepted Solution

    I normally do i with AutoIT it's alot simpler than just include it within the InnoSetup Install

    An AutoIT Script would look something like code snippet below.  The message will continue to loop until the processes are closed.

    AutoIT is free and can be downloaded from also recommend downloading the AutoIT Script Editor as well found on the same page.

    After installing, just save the code below to a new file and call it ProcessClose.au3 (for example) right click the file and select compile script.

    That's it, you should find ProcessClose.exe in the same directory.

    Hope that helps.

    While 1
    	$PROCESS1 = ProcessExists('process1.exe')
    	$PROCESS2 = ProcessExists('process2.exe')
    	If $PROCESS1 Then
    		MsgBox(0,'Error', 'Please Close Application1')
    	ElseIf $PROCESS2 Then
    		MsgBox(0,'Error', 'Please Close Application2')

    Open in new window


    Author Comment

    Thanks. I really need it as part of an Inno script.   Can I  integrate this into Inno?
    LVL 29

    Expert Comment

    You can easily call it for example if it's in the same folder using {src} otherwise if you solely wish to use innosetup than lookup mutexes, CheckForMutexes

    Author Comment

    Many Thanks.  Another solution  is at

    Source: ..\source\psvince.dll; Flags: dontcopy

    (* We declare variables in var section. Inno Setup use Pascal as its script *)
    function IsModuleLoaded(modulename: String ):  Boolean; external 'IsModuleLoaded@files:psvince.dll stdcall';

    function InitializeSetup(): Boolean;

      // check if notepad is running
      if IsModuleLoaded( 'notepad.exe' ) then
        MsgBox( 'Notepad is running, please close it and run again setup.',
                 mbError, MB_OK );
        Result := false;
      else Result := true;

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    This is an explanation of a simple data model to help parse a JSON feed
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    754 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

    16 Experts available now in Live!

    Get 1:1 Help Now