Rishi
Rishi

Reputation: 321

How to detect an existing installation of IIS using INNO setup?

I am looking for a way to determine if the user already has a version of IIS installed. If he doesn't, I will go ahead and run my IIS installation script.

I know of the exception handling clause where I do :

  try
    IIS := CreateOleObject('IISNamespace');  
  except  
    RaiseException(ExceptionType, ‘IIS not installed. Setup will now install IIS on your machine. ’#13#13'(Error ‘’’+ExceptionParam+’’’ occured)’);  
  end;

but for some reason, my compiler version doesn't seem to recognise RaiseException. I also tried including

uses  
SysUtils;  

but the compiler won't recognize SysUtils even. Is there something like a registry key that I can look at to determine whether IIS is already installed or not?
Any help would be much appreciated.

Upvotes: 3

Views: 3249

Answers (3)

Armand Colleye
Armand Colleye

Reputation: 41

Try:

[CustomMessages]
iis_title=Internet Information Services (IIS)


[Code]
function iis(): boolean;
begin
    if not RegKeyExists(HKLM, 'SYSTEM\CurrentControlSet\Services\W3SVC\Security') then
        MsgBox(FmtMessage(CustomMessage('depinstall_missing'), [CustomMessage('iis_title')]), mbError, MB_OK)
    else
        Result := true;
end

;

Upvotes: 2

Lex Li
Lex Li

Reputation: 63244

IIS always installs to %windir%\system32\inetsrv so you should check if specific files exist under this directory. For example, w3wp.exe should exist in this folder for IIS 6/7.

Upvotes: 2

RRUZ
RRUZ

Reputation: 136431

Rishi you are using the RaiseException function with 2 parameters, but the this function only support one.

procedure RaiseException(const Msg: String);

try using this function like this

var
 IIS : variant;
begin    
  try
    IIS := CreateOleObject('IISNamespace');
  except
    RaiseException('IIS not installed. Setup will now install IIS on your machine');
  end;
end;

Upvotes: 4

Related Questions