CryoEnix Posted June 23, 2005 Posted June 23, 2005 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.] Quote Chaos is merely logic beyond human comprehension
jmcilhinney Posted June 23, 2005 Posted June 23, 2005 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. Quote
Administrators PlausiblyDamp Posted June 23, 2005 Administrators Posted June 23, 2005 http://www.xtremedotnettalk.com/showthread.php?t=90500 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CryoEnix Posted June 23, 2005 Author Posted June 23, 2005 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... Quote Chaos is merely logic beyond human comprehension
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.