zoukankan      html  css  js  c++  java
  • 如何利用WMI远程重启远程计算机

    using System;
    using System.Management;
    namespace WMI3
    {
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
    static void Main(string[] args)
    {
    Console.WriteLine("Computer details retrieved using Windows Management Instrumentation (WMI)"); Console.WriteLine("mailto:Written%2002/01/02%20By%20John%20O'Donnell%20-%20csharpconsulting@hotmail.com");
    Console.WriteLine("========================================
    =================================");
    //连接远程计算机
    ConnectionOptions co = new ConnectionOptions(); co.Username = "john" co.Password = "john" System.Management.ManagementScope ms = new System.Management.ManagementScope("\\\\192.168.1.2\\root\\cimv2", co);
    //查询远程计算机
    System.Management.ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem");

    ManagementObjectSearcher query1 = new ManagementObjectSearcher(ms,oq); ManagementObjectCollection queryCollection1 = query1.Get(); foreach( ManagementObject mo in queryCollection1 ) { string[] ss={""}; mo.InvokeMethod("Reboot",ss); Console.WriteLine(mo.ToString()); } } } }

  • 相关阅读:
    一、redis的简介与安装
    三、Mybatis全局配置文件说明
    第七章、本地方法栈
    第六章、本地方法接口
    二、MyBatis接口开发
    第五章、虚拟机栈
    一、Mybatis入门
    第八章、声明式事务管理
    第七章、JdbcTemplate
    第六章、以XML方式配置切面
  • 原文地址:https://www.cnblogs.com/zhucl1006/p/646605.html
Copyright © 2011-2022 走看看