G
Guest
Hi,
is there any easy way to restart my computer... I have XP installed on my
machin.
I have tried this code but it is not working, I am getting an exception
every time it runs.
ManagementClass W32_OS = new ManagementClass("Win32_OperatingSystem");
ManagementBaseObject inParams, outParams;
int result;
W32_OS.Scope.Options.EnablePrivileges = true;
foreach(ManagementObject obj in W32_OS.GetInstances())
{
inParams = obj.GetMethodParameters("Win32Shutdown");
inParams["Flags"] =ShutDown.ForcedReboot;
inParams["Reserved"] = 0;
outParams = obj.InvokeMethod("Win32Shutdown", inParams,null);
result = Convert.ToInt32(outParams["returnValue"]);
}
An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll
Additional information: Privilege not held.
thank u
is there any easy way to restart my computer... I have XP installed on my
machin.
I have tried this code but it is not working, I am getting an exception
every time it runs.
ManagementClass W32_OS = new ManagementClass("Win32_OperatingSystem");
ManagementBaseObject inParams, outParams;
int result;
W32_OS.Scope.Options.EnablePrivileges = true;
foreach(ManagementObject obj in W32_OS.GetInstances())
{
inParams = obj.GetMethodParameters("Win32Shutdown");
inParams["Flags"] =ShutDown.ForcedReboot;
inParams["Reserved"] = 0;
outParams = obj.InvokeMethod("Win32Shutdown", inParams,null);
result = Convert.ToInt32(outParams["returnValue"]);
}
An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll
Additional information: Privilege not held.
thank u