473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Reboot With System.Management

Any idea how to reboot a givin machine useing the
ststem.management namespace?
thanks eric.
Nov 22 '05 #1
3 4776
Hi, Eric

Andy Cheung posted the following last year:

in System.Management, you would set ConnectionOptions.EnablePrivileges
property to true to enable privileges. There is a bug in .NET Framework
v1.0 that prevents privileges from working correctly when the calling
thread is STA. Make your calling thread as MTA as a workaround.

//[STAThread] // For .NET Framework v1.0, comment this to work
around in C#. Add "<MTAThread()> _" in VB.NET.
public static void Main()
{
ManagementClass osClass = new ManagementClass("Win32_OperatingSystem");

osClass.Scope.Options.EnablePrivileges = true;
foreach (ManagementObject os in osClass.GetInstances())
{
ManagementBaseObject outParams = os.InvokeMethod("Reboot", null,
null);
Console.WriteLine("OS is {0}", os["Caption"]);
Console.WriteLine("Executing Win32_OperatingSystem.Reboot returns
{0}", outParams["ReturnValue"]);
}
}

Please get back to me and let me know if this works for you.

HTH,

John Eikanger
Microsoft Developer Support

This posting is provided “AS IS” with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation. All rights reserved.

--------------------
| Content-Class: urn:content-classes:message
| From: "------------------ eric --------------------" <en******@bpa.gov>
| Sender: "------------------ eric --------------------" <en******@bpa.gov>
| Subject: Reboot With System.Management
| Date: Thu, 24 Jul 2003 08:57:30 -0700
| Lines: 5
| Message-ID: <01****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNR/EmbwICw3EWATZKra91xved5Pg==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:102311
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Any idea how to reboot a givin machine useing the
| ststem.management namespace?
|
|
| thanks eric.
|

Nov 22 '05 #2
Hi, Eric

Andy Cheung posted the following last year:

in System.Management, you would set ConnectionOptions.EnablePrivileges
property to true to enable privileges. There is a bug in .NET Framework
v1.0 that prevents privileges from working correctly when the calling
thread is STA. Make your calling thread as MTA as a workaround.

//[STAThread] // For .NET Framework v1.0, comment this to work
around in C#. Add "<MTAThread()> _" in VB.NET.
public static void Main()
{
ManagementClass osClass = new ManagementClass("Win32_OperatingSystem");

osClass.Scope.Options.EnablePrivileges = true;
foreach (ManagementObject os in osClass.GetInstances())
{
ManagementBaseObject outParams = os.InvokeMethod("Reboot", null,
null);
Console.WriteLine("OS is {0}", os["Caption"]);
Console.WriteLine("Executing Win32_OperatingSystem.Reboot returns
{0}", outParams["ReturnValue"]);
}
}

Please get back to me and let me know if this works for you.

HTH,

John Eikanger
Microsoft Developer Support

This posting is provided “AS IS” with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation. All rights reserved.

--------------------
| Content-Class: urn:content-classes:message
| From: "------------------ eric --------------------" <en******@bpa.gov>
| Sender: "------------------ eric --------------------" <en******@bpa.gov>
| Subject: Reboot With System.Management
| Date: Thu, 24 Jul 2003 08:57:30 -0700
| Lines: 5
| Message-ID: <01****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNR/EmbwICw3EWATZKra91xved5Pg==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:102311
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Any idea how to reboot a givin machine useing the
| ststem.management namespace?
|
|
| thanks eric.
|

Nov 22 '05 #3
Hi, Eric

Andy Cheung posted the following last year:

in System.Management, you would set ConnectionOptions.EnablePrivileges
property to true to enable privileges. There is a bug in .NET Framework
v1.0 that prevents privileges from working correctly when the calling
thread is STA. Make your calling thread as MTA as a workaround.

//[STAThread] // For .NET Framework v1.0, comment this to work
around in C#. Add "<MTAThread()> _" in VB.NET.
public static void Main()
{
ManagementClass osClass = new ManagementClass("Win32_OperatingSystem");

osClass.Scope.Options.EnablePrivileges = true;
foreach (ManagementObject os in osClass.GetInstances())
{
ManagementBaseObject outParams = os.InvokeMethod("Reboot", null,
null);
Console.WriteLine("OS is {0}", os["Caption"]);
Console.WriteLine("Executing Win32_OperatingSystem.Reboot returns
{0}", outParams["ReturnValue"]);
}
}

Please get back to me and let me know if this works for you.

HTH,

John Eikanger
Microsoft Developer Support

This posting is provided “AS IS” with no warranties, and confers no rights.
(c) 2003 Microsoft Corporation. All rights reserved.

--------------------
| Content-Class: urn:content-classes:message
| From: "------------------ eric --------------------" <en******@bpa.gov>
| Sender: "------------------ eric --------------------" <en******@bpa.gov>
| Subject: Reboot With System.Management
| Date: Thu, 24 Jul 2003 08:57:30 -0700
| Lines: 5
| Message-ID: <01****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNR/EmbwICw3EWATZKra91xved5Pg==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:102311
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Any idea how to reboot a givin machine useing the
| ststem.management namespace?
|
|
| thanks eric.
|

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ---------- Eric ---------- | last post by:
How would i go about rebooting a remote computer from code running on this local computer? Bacsically i have a service running on machine A, it checks the status of a service on machine B. If...
1
by: ------------------ eric -------------------- | last post by:
Any idea how to reboot a givin machine useing the ststem.management namespace? thanks eric.
1
by: eric | last post by:
I have a need to reboot a remote machine from code that is running on a local machine. I would assume that i need to use WMI and the system.management namespace. Any ideas? Code Samples? ...
0
by: Allan Bredahl | last post by:
Hi All I am trying to construct an application that is able to cancel a machine shutdown, reboot or logoff. And after performing some stuff to perform the original shutdown order :...
0
by: Manoj Nair | last post by:
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...
6
by: Herbert VON GRÜNENWALD | last post by:
in c++ it was ExitWindowsEx() thanks
3
by: sam | last post by:
I found reboot script at TechNet and I wonder how to apply in VB.Net? Reboot Coding ************ strComputer = "." Set objWMIService = GetObject("winmgmts:" _ &...
1
by: Aaron | last post by:
Not sure if this is the best spot to post this question, but I am not going to pay money to ask an installation question.... Anyways I am trying to install C# standard 2003 and it analyzes the...
8
by: Avi G | last post by:
Hi, what is the quick code in C# for reboot local machine? Thanks.
1
by: =?Utf-8?B?SmVmZg==?= | last post by:
Is there a .NET class for rebooting XP and specifying the program to run on reboot? Thanks, jeff
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.