Solved

how can i programmatically restart iis

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now