Abhi
using System;
using System.Management;
using System.Runtime.InteropServices;
// Shutdown a system using WMI (management classes)
public class Wmis {
public static void Main() {
ManagementObject o;
ManagementPath path = new ManagementPath( );
path.Server = "."; // . for the local server or the server name if a remote server
path.NamespacePath = @"root\CIMV2";
// check your boot.ini file for the correct operating system entry & boot partition
path.RelativePath = @"Win32_OperatingSystem.Name=""Microsoft Windows XP
Professional|C:\\WINNT|\\Device\\Harddisk0\\Partition1""";
o = new ManagementObject(path);
ManagementBaseObject inParams = null;
bool EnablePrivileges = o.Scope.Options.EnablePrivileges; // set required privileges
o.Scope.Options.EnablePrivileges = true;
// Invoke method (shutdown or reboot)
ManagementBaseObject outParams = o.InvokeMethod("Shutdown", inParams, null);
o.Scope.Options.EnablePrivileges = EnablePrivileges; // restore privs (optional)
}
}
Willy.
"Abhi" <source...@hotmail.com> wrote in message news:#4Vj7IReBHA.552@tkmsftngp02...