470,632 Members | 2,706 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,632 developers. It's quick & easy.

Problem of Reboot in WMI application

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
Nov 16 '05 #1
0 1341

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.