Solved

how can i programmatically restart iis

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 115
Vb.net 2008 2 60
Updates not working for MS Windows 7 12 166
Error when passing an argument to a vb6 that contains  '/' 7 37
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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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