473,394 Members | 1,715 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,394 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 4774
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.