Solved

how can i programmatically restart iis

Posted on 2002-05-07
2
1,161 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now