Click here to Skip to main content
15,793,368 members
Home / Discussions / C#
   

C#

 
GeneralRe: asking for system tray application Pin
Heath Stewart13-Jan-04 5:53
protectorHeath Stewart13-Jan-04 5:53 
Questionreturning when inside a lock - is it safe? Pin
Brandon Haase12-Jan-04 16:29
Brandon Haase12-Jan-04 16:29 
AnswerRe: returning when inside a lock - is it safe? Pin
Heath Stewart13-Jan-04 5:46
protectorHeath Stewart13-Jan-04 5:46 
GeneralRe: returning when inside a lock - is it safe? Pin
Brandon Haase13-Jan-04 17:13
Brandon Haase13-Jan-04 17:13 
AnswerRe: returning when inside a lock - is it safe? Pin
scadaguy13-Jan-04 6:23
scadaguy13-Jan-04 6:23 
GeneralRe: returning when inside a lock - is it safe? Pin
Brandon Haase13-Jan-04 17:28
Brandon Haase13-Jan-04 17:28 
Generalremoting access Pin
haih12-Jan-04 16:23
haih12-Jan-04 16:23 
GeneralRe: remoting access Pin
Heath Stewart13-Jan-04 5:31
protectorHeath Stewart13-Jan-04 5:31 
The WMI support in .NET is superb. The best way to do this is to create a new project, then open your Server explorer (the "Server" tab next to the "Toolbox" in the default VS.NET installation) add your computer unders Servers (if it isn't already), then drill-down the find the Management Classes node. If you don't see them, download the setup at http://go.microsoft.com/fwlink/?LinkId=3353[^].

Now find the Operating Systems node. Right-click and click Generate Managed Class. Now you have the Win32_OperatingSystem class encapsulated in a .NET class you can use in many ways! This will have several methods for what you need, such as a Shutdown and Reboot method.

You can then, for example, reboot a named machine like so:
ManagementScope scope = new ManagementScope(
  string.Format(@"\\{0}\ROOT\CIMV2", name));
Sample.ROOT.CIMV2.OperatingSystem.OperatingSystemCollection systems = 
  Sample.ROOT.CIMV2.OperatingSystem.GetInstances(scope, null, null);
foreach (Sample.ROOT.CIMV2.OperatingSystem system in systems)
  system.Reboot();
Sample is the just the namespace I used to write the example code. The Sample.ROOT.CIMV2 namespaces and the classes and nested classes therein where generated from the step above.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralHelp with MonthCalendar class Pin
KingTermite12-Jan-04 16:18
KingTermite12-Jan-04 16:18 
GeneralRe: Help with MonthCalendar class Pin
Heath Stewart13-Jan-04 4:41
protectorHeath Stewart13-Jan-04 4:41 
GeneralRe: Help with MonthCalendar class Pin
KingTermite13-Jan-04 5:27
KingTermite13-Jan-04 5:27 
GeneralRe: Help with MonthCalendar class Pin
Heath Stewart13-Jan-04 5:37
protectorHeath Stewart13-Jan-04 5:37 
GeneralRe: Help with MonthCalendar class Pin
KingTermite13-Jan-04 6:43
KingTermite13-Jan-04 6:43 
GeneralRe: Help with MonthCalendar class Pin
Heath Stewart13-Jan-04 6:50
protectorHeath Stewart13-Jan-04 6:50 
GeneralRe: Help with MonthCalendar class Pin
KingTermite13-Jan-04 7:02
KingTermite13-Jan-04 7:02 
GeneralRe: Help with MonthCalendar class Pin
Heath Stewart13-Jan-04 7:47
protectorHeath Stewart13-Jan-04 7:47 
GeneralRe: Help with MonthCalendar class Pin
KingTermite15-Jan-04 15:49
KingTermite15-Jan-04 15:49 
GeneralRe: Help with MonthCalendar class Pin
Heath Stewart16-Jan-04 4:42
protectorHeath Stewart16-Jan-04 4:42 
GeneralFile Permissions Pin
krisp12-Jan-04 15:54
krisp12-Jan-04 15:54 
GeneralRe: File Permissions Pin
Jeff Mackie12-Jan-04 18:33
sussJeff Mackie12-Jan-04 18:33 
GeneralRe: File Permissions Pin
krisp12-Jan-04 18:36
krisp12-Jan-04 18:36 
GeneralRe: File Permissions Pin
Jeff Mackie12-Jan-04 18:48
sussJeff Mackie12-Jan-04 18:48 
GeneralRe: File Permissions Pin
Heath Stewart13-Jan-04 3:57
protectorHeath Stewart13-Jan-04 3:57 
QuestionHow can I use the Cabinet.dll in c# Pin
aw1ay12-Jan-04 15:32
aw1ay12-Jan-04 15:32 
AnswerRe: How can I use the Cabinet.dll in c# Pin
Heath Stewart13-Jan-04 3:52
protectorHeath Stewart13-Jan-04 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.