Restart Service on Remote
ServiceController sc = new ServiceController("serviceName", "Mahcine ip/name");
sc.Start();
sc.Stop();
restart machine
string systemname;= XXXXXX;systemnameProcess.Start("shutdown", "-r -f -m \\\\\"+);systemname
ConnectionOptions conn = new ConnectionOptions();conn.Username = "test";conn.Password = "test"; System.Management.ManagementScope ms = new System.Management.ManagementScope("\\\\IP\\root\\cimv2", co); //Query remote computer across the connectionSystem.Management.ObjectQuery objq = new System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem"); ManagementObjectSearcher qry = new ManagementObjectSearcher(ms,objq); ManagementObjectCollection col =qry.Get(); foreach( ManagementObject mobj incol) { string[] ss={""};mobj.InvokeMethod("Reboot",ss); Console.WriteLine(mobj.ToString()); }

No comments:
Post a Comment
Note: Only a member of this blog may post a comment.