Solved

how can i programmatically restart iis

Posted on 2002-05-07
2
1,166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Title # Comments Views Activity
using Access 8 94
Notepad++ how to remove delimiter : from beggning of the line? 3 135
IF ELSE Statement in Excel Macro VBA 16 103
Help with Classic ASP - Parameterizing Query 16 65
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.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

751 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