• λ我爱Aspx >> Asp.Net >> 使用C#控制远程计算机的服务
  • 使用C#控制远程计算机的服务

  • :未知  Դ:internet  :2007-5-20 16:43:53  ؼ:c#
  • {

    ConnectionOptions connectionOptions = new ConnectionOptions();

    connectionOptions.Username = userName;

    connectionOptions.Password = password;

    ManagementScope managementScope = new ManagementScope( "\\\\" +host+ "\\root\\cimv2",connectionOptions) ;

    try

    {

    managementScope.Connect();

    }

    catch

    {

    }

    return managementScope.IsConnected;

    }

    // 获取指定服务属性的值

    public object GetServiceValue(string serviceName,string propertyName)

    {

    ManagementObject mo = this.managementClass.CreateInstance();

    mo.Path = new ManagementPath(this.strPath+".Name=\""+serviceName+"\"");

    return mo[propertyName];

    }

    // 获取所连接的计算机的所有服务数据

    public string [,] GetServiceList()

    {

    string [,] services = new string [this.managementClass.GetInstances().Count,4];

    Ҷƪл˵?
  • һƪ使用C#调用外部Ping命令获取网络连接情况
    һƪ使用C#编写的一个定时关机程序