How to remotely restart a remote computer Using WMI

Source: Internet
Author: User

using system;
using system. management;
namespace wmi3
{< br> ///


/// summary description for class1.
///
class class1
{< br> static void main (string [] ARGs)
{< br> console. writeline ("Computer details retrieved using Windows Management Instrumentation (Wmi)"); console. writeline ("mailto: Written % 2002/01/02% 20by % 20 John % 20o 'Donnell % 20-% 20csharpconsulting@hotmail.com");
console. writeline ("========================================== ====< BR >=======================================" );
// connect to a remote computer
connectionoptions CO = new connectionoptions (); Co. username = "John" Co. password = "John" system. management. management scope MS = new system. management. managementscope ("\\\\ 192.168.1.2 \\ Root \ cimv2", CO);
// query remote computers
system. management. objectquery OQ = new system. management. objectquery ("select * From win32_operatingsystem");

New managementobjectsearcher (MS, OQ); managementobjectcollection querycollection1 = query1.get (); foreach (managementobject Mo in querycollection1) {string [] Ss = {""}; mo. invokemethod ("reboot", SS); console. writeline (MO. tostring () ;}}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.