Hi Harish,
This could be achieved with the use of two custom actions.
The first custom action is to be executed at the beginning of the install process and it will stop the IIS. For example, you can schedule it under the "InstallInitialize" standard action.
Here is a VBScript that stops the IIS server:
Code: Select all
Const SITE_STOPPED = 4
Set objIIsWebService = GetObject("IIS://localhost/W3SVC")
For Each Site in objIIsWebService
If Site.Class = "IIsWebServer" Then
Set objIIsWebServer = GetObject(Site.ADsPath)
intStatus = objIIsWebServer.Status
If intStatus <> SITE_STOPPED Then
objIIsWebServer.Stop
WScript.Sleep 3000
intStatus = objIIsWebServer.Status
If intStatus = SITE_STOPPED Then
WScript.Echo "Web server stopped."
Else
WScript.Echo "The Web server did not stop."
End If
Else
WScript.Echo "The Web server is already stopped."
End If
End If
Next
The second custom action is to be execute at the end of the installation say, under the "InstallFinalize" standard action. This custom action will restart the IIS.
Here is a VBScrip that does that:
Code: Select all
Const SITE_STARTED = 2
Set objIIsWebService = GetObject("IIS://localhost/W3SVC")
For Each Site in objIIsWebService
If Site.Class = "IIsWebServer" Then
Set objIIsWebServer = GetObject(Site.ADsPath)
intStatus = objIIsWebServer.Status
If intStatus <> SITE_STARTED Then
objIIsWebServer.Start
WScript.Sleep 3000
intStatus = objIIsWebServer.Status
If intStatus = SITE_STARTED Then
WScript.Echo "Web server started."
Else
WScript.Echo "The Web server did not start."
End If
Else
WScript.Echo "The Web server is already started."
End If
End If
Next
Best regards,
Ciprian