cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
alejandrogarino
Level 2

Activating Windows features (IIS) from InstallScript Project

Hello,

I'm working on an InstallScript project and I need to set as prerequisite that the user must have the IIS installed and activated.
Is there a way to achive this from inside the project?
Otherwise, which would be the correct way to do this?

Thanks in advance.

Alejandro
Labels (1)
0 Kudos
(4) Replies
ch_eng
Level 7

Alejandro,

With InstallScript, you could try something like this:


OBJECT objIISRoot;
...

// Check for IIS
try
set objIISRoot = CoGetObject("IIS://Localhost/W3svc", "");
if IsObject( objIISRoot ) then
//IIS is installed; might want to check version number
else
//error: Couldn't verify IIS (couldn't get root virtual directory)"
endif;
catch
//error: Unable to verify the existence of IIS on this system.
endcatch;


To verify that the IIS Admin and W3SVC services are not disabled, check these registry keys. A "Start" value of 0x00000004 means the service's startup type is Disabled. You can test the value by just comparing it to "4".

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\IISAdmin
[Start]

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W3SVC
[Start]


HTH
0 Kudos
alejandrogarino
Level 2

Thank you ch_eng for the answer!

Where should I put this code? I mean, in which event would it be the best place to make this validation?
On the other hand, is there a way to install or activate IIS by code in case he doesn't have it?

Thanks!

Alejandro
0 Kudos
ch_eng
Level 7

Alejandro,

I would recommend checking for this near the beginning of:

function OnFirstUIBefore()


Sorry, I do not know how to install or activate IIS if it is missing.

HTH
0 Kudos
Kelter
Level 10

what version of IIS are you using? Or rather, what server? For IIS 6 (Windows Svr 03) you can use

Sysocmgr.exe /i:[WindowsFolder]inf\sysoc.inf /u:[SUPPORTDIR]\IISAnswer.txt

I haven't yet looked into the IIS 7/Svr08 method, but whoever gets to it first should update this post. I think Svr08 comes with the IIS role already enabled, but it's been a while since I last set a Svr08 machine up, that I don't remember.

Oh, as for detection, look in

HKLM\System\CurrentControlSet\Services\W3Svc\Parameters
Name: MajorVersion

if you find a 6, then IIS 6 is already set up.
0 Kudos