using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;namespace Wind
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Todo(h.Text, m.Text, z.Text, "Reboot");
} private void Todo(string name,string pass,string ip,string fo)
{
ConnectionOptions op = new ConnectionOptions();
op.Username = name;
op.Password = pass;
ManagementScope scope = new ManagementScope("\\\\"+ip+"\\root\\cimv2:Win32_Service",op);
try
{
scope.Connect();
System.Management.ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher qu = new ManagementObjectSearcher(scope,oq);
ManagementObjectCollection c = qu.Get();
foreach (ManagementObject mo in c)
{
string[] str ={ "" };
mo.InvokeMethod(fo, str);
}
MessageBox.Show("成功");
}
catch (Exception e)
{
MessageBox.Show("失败");
}
} private void guan_Click(object sender, EventArgs e)
{
Todo(h.Text, m.Text, z.Text, "Shutdown");
} private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
} private void Form1_Load(object sender, EventArgs e)
{
}
}
}
////////////////////////
为啥局域网好用,internet不好用那(ip,帐号,密码都正确)!!
////////////////////////
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Management;namespace Wind
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Todo(h.Text, m.Text, z.Text, "Reboot");
} private void Todo(string name,string pass,string ip,string fo)
{
ConnectionOptions op = new ConnectionOptions();
op.Username = name;
op.Password = pass;
ManagementScope scope = new ManagementScope("\\\\"+ip+"\\root\\cimv2:Win32_Service",op);
try
{
scope.Connect();
System.Management.ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher qu = new ManagementObjectSearcher(scope,oq);
ManagementObjectCollection c = qu.Get();
foreach (ManagementObject mo in c)
{
string[] str ={ "" };
mo.InvokeMethod(fo, str);
}
MessageBox.Show("成功");
}
catch (Exception e)
{
MessageBox.Show("失败");
}
} private void guan_Click(object sender, EventArgs e)
{
Todo(h.Text, m.Text, z.Text, "Shutdown");
} private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
} private void Form1_Load(object sender, EventArgs e)
{
}
}
}
////////////////////////
为啥局域网好用,internet不好用那(ip,帐号,密码都正确)!!
////////////////////////
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货