title: How to restart a service with VB.NET?
body: <p>Ok, so I'm new to VB.NET and trying to write a program that prompts the user for a server name and then restarts the IIS on that machine. </p>
  
  <p>Problem 1) namespace <code>System.ServiceProcess</code> is not being recognized.<br>
  Problem 2) need help with code, passing servername into sub.</p>
  
  <pre><code>Imports System
  Imports System.ServiceProcess
  Imports System.IO
  Imports System.Threading
  
  Class RestartIIS
      Shared Sub Main()
          Run()
      End Sub
  
      Public Sub Run()
          Console.WriteLine("Please enter the Server Name: ")
          Dim ServerName As String = Console.ReadLine()
  
          Dim sc As ServiceController = New ServiceController("W3SVC")
  
          sc.Stop()
          Thread.Sleep(2000)
          sc.Start()
  
          Console.Write("Press Enter to Exit")
          Console.ReadLine()
      End Sub
  End Class 
  </code></pre>