Hi,
I am writing a console application using WMI with C# . Development is for
Windows XP machine. One of the methods requires to reboot the local
terminal.
In my application I make a call to the Reboot method of the
Win32_OperatingSystem class.
Even though I am the local administrator on this system which is a Windows
XP machine ..
Trying this out on the Domain administrator's PC with his login also didnt
work.
I get an error message .
I give the code as well as the error message below.
..............Code ...............................
ManagementClass objMC = new ManagementClass(
"Win32_OperatingSystem");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach(ManagementObject objMO in objMOC)
{
ManagementBaseObject iPar = null;
bool EnablePriviledge = objMO.Scope.Options.EnablePrivileges;
objMO.Scope.Options.EnablePrivileges =true;
ManagementBaseObject outPar = objMO.InvokeMethod("Reboot",iPar,null);
}
------------------------------------
Error Message...
System.Management.ManagementException: Privilege not held.
at
System.Management.ManagementException.ThrowWithExt endedInfo(ManagementStat
us errorCode)
at System.Management.ManagementObject.InvokeMethod(St ring methodName,
Managem
entBaseObject inParameters, InvokeMethodOptions options)
at Aloha.RAL.CConfigTerm.get_RebootTerminal() in
E:\Projects\Radiants\Remote
Application Loader\WF\Aloha\Aloha.RAL\ConfigTerm.cs:line 126
--------------------------------------------------------
Links url :
for Win32_OperatingSystem
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
win32_operatingsystem.asp
for Reboot method
http://msdn.microsoft.com/library/de...us/wmisdk/wmi/
reboot_method_in_class_win32_operatingsystem.asp
thanks for any help
regards
Manoj