.NET Shutdown / Reboot Command
4 posts
• Page 1 of 1
.NET Shutdown / Reboot Command
Does anyone know the command to reboot or shutdown a machine when programming with VB.net or C#.net? Or even just the actual application (if it is one ) that shuts down / reboots your machine?
Thanks in advance!
-Jonny
- jonnywright
- Banned
- Posts: 53
- Joined: Thu Aug 14, 2003 10:25 pm
- Location: Leicester UK
I am not much of a programmer in a Windows environment, but the dll you are going to want to call is rundll32.dll, pass a few parameters to rundll32.dll and you can shutdown, reboot, logout, etc . There are a couple similar ways of doing it.
http://listas.rcp.net.pe/pipermail/wind ... 01652.html
There's a great link, will do a much better job explaining it than I can.
-Weaver
Public Keys
The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
- Weaver
- PROfessional Member
- Posts: 1967
- Joined: Wed Jun 19, 2002 12:05 am
- Location: /home/weaver/
If you're running Windows XP you can do this (Note: You need to have admin-privelages to do this.):
From DOS Console
So if you wanted to restart (instantly) the command-line equiv. would be:
shutdown -r -t 0
Also, if your computer decides it wants to shutdown (like if SVCHost.exe was terminated, etc) you can use the -a switch to continue working.
I know that in C/C++ you can use: "system()", and whatever was in the parenthesis would be executed @ command-line...but I'm not sure if this holds true for C#... =/
Hope that helped =)
-Hari
From DOS Console
- Code: Select all
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "c
omment"] [-d up:xx:yy]
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without war
ning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer le
ss than 256)
yy is the minor reason code (positive integer le
ss than 65536)
So if you wanted to restart (instantly) the command-line equiv. would be:
shutdown -r -t 0
Also, if your computer decides it wants to shutdown (like if SVCHost.exe was terminated, etc) you can use the -a switch to continue working.
I know that in C/C++ you can use: "system()", and whatever was in the parenthesis would be executed @ command-line...but I'm not sure if this holds true for C#... =/
Hope that helped =)
-Hari
4 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 5 guests