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

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

    private string strPath;

    private ManagementClass managementClass;

    public Win32ServiceManager():this(".",null,null)

    {

    }

    public Win32ServiceManager(string host,string userName,string password)

    {

    this.strPath = "\\\\"+host+"\\root\\cimv2:Win32_Service";

    this.managementClass = new ManagementClass(strPath);

    if(userName!=null&&userName.Length>0)

    {

    ConnectionOptions connectionOptions = new ConnectionOptions();

    connectionOptions.Username = userName;

    connectionOptions.Password = password;

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

    this.managementClass.Scope = managementScope;

    }

    }

    // 验证是否能连接到远程计算机

    public static bool RemoteConnectValidate(string host,string userName,string password)

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