[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2529
  • 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....
0
SarusSystems
Asked:
SarusSystems
  • 2
  • 2
1 Solution
 
matrixnzCommented:
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.

Cheers
#NoTrayIcon
 
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')
	Else
		ExitLoop
	EndIf
WEnd

Open in new window

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

[Files]
Source: ..\source\psvince.dll; Flags: dontcopy

[Code]
(* 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;
begin

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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