473,434 Members | 1,394 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,434 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 4780
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.