Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey guys, I've been writing a program that does a specific task at a set time, and it can now execute files. However, I also need it to be able to shut down the PC too. I've written this before, but it only worked on win9x machines with VB6, and now I'm working with XP in VB.NET.

Are there any ways to shut down the PC through .NET? And how might I go about this? I've googled, I've searched the forums, I've asked Satan himself. Can't seem to find anything.

 

[Edit - forgot to subscribe. Duh.]

Chaos is merely logic beyond human comprehension
Posted
This option works for XP and I think 2000 as well. Other Windows versions possibly not. There is a utility in the system32 folder called "shutdown.exe" that can be called using Process.Start. Check the Windows help for all the options, which are fairly extensive. For an option that is a litle more involved but will work on Windows back to 95, search MSDN for the ExitWindowsEx API.
Posted

Cheers to the pair of you, I'll look into both strats now. Winner gets a muffin.

 

Oh, and shelling the shutdown.exe? That's so simple it never even occurred to me...

Chaos is merely logic beyond human comprehension

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...