Stoping IIS serverV1


Does anyone have any idea how to stop the IIS http server programaticly with VB? just as it the "stop" button was pressed on the management console?

Who is Participating?
kwkConnect With a Mentor Commented:
It's pretty simple

Private Sub CmdStop_Click()
    Path = "IIS://localhost/W3SVC/1"
    Action = "setstate"
    Set currentobj = GetObject(Path)
End Sub

Private Sub CmdStart_Click()
    Path = "IIS://localhost/W3SVC/1"
    Action = "setstate"
    Set currentobj = GetObject(Path)
End Sub

In the path string, the number at the end, is the iis' internal reference to the website. Se below if you don't know how to find it.

To find the websites number:

In the MMC
- Click the website that you will find.
- Rightclick and choose properties
- Click properties on the button next to the loggin settings

You will now see the logfilename.
It starts in the directory "W3SVC1"
The number in the end of W3SVC1 is the number you want to see.

Good luck


Kim Kähler

martinnetquoteAuthor Commented:
Adjusted points to 200
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.