• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2637
  • Last Modified:

Inno Setup. Detect if an EXE is running

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....
  • 2
  • 2
1 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 http://www.autoitscript.com/autoit3/downloads.shtml 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

SarusSystemsAuthor Commented:
Thanks. I really need it as part of an Inno script.   Can I  integrate this into Inno?
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
SarusSystemsAuthor Commented:
Many Thanks.  Another solution  is at http://www.vincenzo.net/isxkb/index.php?title=Call_psvince.dll_on_install_and_uninstall

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;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now