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.
Problem 1) namespace System.ServiceProcess
is not being recognized.
Problem 2) need help with code, passing servername into sub.
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