Solved

how can i programmatically restart iis

Posted on 2002-05-07
2
1,164 Views
Last Modified: 2007-12-19
how can i programmatically restart iis and capture when it is back up?


igoor
0
Comment
Question by:igoor
2 Comments
 
LVL 17

Accepted Solution

by:
inthedark earned 100 total points
ID: 6993547

Load a list of services you want to stop into a text file:

Start them up in reverse order.
You may want to stop other services.....

Have fun, inthedark....-




Option Explicit
Private Const INFINITE = &HFFFF ' (Used by run command)
Private Declare Function OpenProcess Lib "kernel32" _
        (ByVal dwAccess As Long, ByVal fInherit As Integer, _
        ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" _
        (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long



Public Function RunCommandOK(CommandLine As String, Optional FocusStyle As VbAppWinStyle = vbNormalFocus) As Boolean
   
    ' runs a batch command of other process until complete
       
    Dim Success As Long
    Dim ProgID As Long
    Dim Handle As Long
    ProgID = Shell(CommandLine, FocusStyle)
    Handle = OpenProcess(&H100000, True, ProgID)
    Success = WaitForSingleObject(Handle, INFINITE)

End Function

Private Sub Command1_Click()
Dim ok

ok = RunCommandOK("net stop ""world wide web publishing service""")
ok = RunCommandOK("net stop ""iis admin service""")
msgbox "Service is stopped"
ok = RunCommandOK("net start ""iis admin service""")
ok = RunCommandOK("net start ""world wide web publishing service""")

End Sub



0
 

Author Comment

by:igoor
ID: 6993559
perfect, thank you very much


igoor
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question