MAIN MENU
News Php Tips Spring+Strut+Hibernate Android Programming Design Pattern By PHP Ubuntu Linux Quick Tips C# Design Pattern C# using Linq น่าใช้จริงๆ C# Tips & Technique Java & JavaScript Tips Database & SQL ZengCode Framework Guide Zeng Code Code Programming IPhone (Tips and Trick)
Download เอกสารที่น่าสนใจ




|
Start IIS Service using C# (2009-09-03)
We can restart the IIS service if it is stopped. Below is the code for starting IIS using C#.
The machine name is nothing but the Computer Name and Servicename is the IIS.
when you click a button in the web page first it will check whether the IIS is running or not.
If not it will restart the IIS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.ServiceProcess;
namespace TipAndTrick
{
public partial class Form1 : Form
{
private ServiceController serviceController1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = serviceController1.Status.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
serviceController1 = new ServiceController();
serviceController1.MachineName = "Remote IP Address";
serviceController1.ServiceName = "Apache2.2";
}
private void button2_Click(object sender, EventArgs e)
{
serviceController1.Start();
}
private void button3_Click(object sender, EventArgs e)
{
serviceController1.Stop();
}
}
} |
.
|
Comment
|
|