Re: WMI and Rebooting

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Willy, I read the article you pointed me to. It seems that the hotfix is
language specific. Is that true? If so, I deal with over 26 languages and
would need a hot fix for each. Any suggestions of how I should proceed?
--
Steve


"Willy Denoyette [MVP]" wrote:

>
> "Steve Teeples" <SteveTeeples@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:0E8985F0-E990-4FB6-B390-6FB601339197@xxxxxxxxxxxxxxxx
> >I am trying to use WMI to reboot my system. I have admin privileges. I've
> > tried two different solutions but both fail for separate reasons.
> >
> > private void button1_Click(object sender, System.EventArgs e)
> > {
> > ManagementBaseObject outParams = null;
> > ManagementClass os = new ManagementClass("Win32_OperatingSystem");
> >
> > os.Scope.Options.EnablePrivileges = true; // enables required security
> > privilege.
> > os.Get();
> > ManagementBaseObject inParams = os.GetMethodParameters("Win32Shutdown");
> > inParams["Flags"] = "2"; // System forced reboot
> > inParams["Reserved"] = "0";
> > foreach (ManagementObject mo in os.GetInstances())
> > outParams = mo.InvokeMethod("Win32Shutdown", inParams, null);
> > }
> >
> > This method gives me a run-time errors with System.Management telling me
> > "Privilege not held."
> >
> > This next attempt, called from the click method, fails with a run-time
> > error
> > saying "Invalid Method Parameter(s)".
> >
> > ManagementClass os = new ManagementClass("Win32_OperatingSystem");
> > os.Scope.Options.EnablePrivileges = true; // enables required security
> > privilege.
> > os.Get();
> > ManagementBaseObject inParams = os.GetMethodParameters("Reboot");
> > ManagementBaseObject outParams = os.InvokeMethod("Reboot", inParams,
> > null);
> >
> > What am I doing wrong? I have .NET 1.1 on my system.
> >
> >
> >
> > --
> > Steve
>
> This is confirmed to be a known problem with v1.1 SP1 (and v1.0 SP3), check
> [1] for a reply from MSFT on microsoft.public.dotnet.framework. for the same
> issue.
>
> Subject: PrivilegeNotHeld, .Net 1.1 sp1 bug, hotfix
> Date: April 24, 2005
>
> Willy.
>
>
>
>
>
>
>
>
>
.


Quantcast