VB icon

Absolutely Fastest, Smallest Code to Shutdown a Windows NT/2000/XP Computer

Email
Submitted on: 2/6/2015 9:00:00 PM
By: Ion Alex Ionescu (from psc cd)  
Level: Beginner
User Rating: By 7 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 3115
 
     This code instantly shuts down any NT-based OS, ie Windows NT 4, Windows 2000, XP, Server 2003, Longhorn, etc. (Not 95/98/Me). I know there's a lot of code on the site that does this, but remember that on NT, things get harder because your process needs the shutdown privilege. Other coders have used Win32 APIs to gain this privilege, but as I have said in my previous articles...the power lies in Native API. In this unique example, only a single API call is needed to enable the privilege, followed by another API call to instantly terminate the computer. If you compile this application, double-clicking on it will shut down your PC within a second. Do what you please with it...it might not be very useful most of the time (because it doesn't save any files), but if you ever need a quick shutdown (let's say you just ran a virus), this is as fast as pulling out the power cord.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Absolutely Fastest, SmallestCode to Shutdown a Windows NT/2000/XP Computer
'**************************************
RtlAdjustPrivileges
NtShutdownSystem
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Absolutely Fastest, SmallestCode to Shutdown a Windows NT/2000/XP Computer
' Description:This code instantly shuts down any NT-based OS, ie Windows NT 4, Windows 2000, XP, Server 2003, Longhorn, etc. (Not 95/98/Me).
I know there's a lot of code on the site that does this, but remember that on NT, things get harder because your process needs the shutdown privilege. Other coders have used Win32 APIs to gain this privilege, but as I have said in my previous articles...the power lies in Native API. 
In this unique example, only a single API call is needed to enable the privilege, followed by another API call to instantly terminate the computer. If you compile this application, double-clicking on it will shut down your PC within a second.
Do what you please with it...it might not be very useful most of the time (because it doesn't save any files), but if you ever need a quick shutdown (let's say you just ran a virus), this is as fast as pulling out the power cord.
' By: Ion Alex Ionescu (from psc cd)
'
' Returns:A closed PC.
'
' Side Effects:Nothing will be saved, instant shutdown.
'**************************************

' // QuikDown 1.0
' // Written by Alex Ionescu
' // İRelsoft Technologies 2004
' // COMMENTS: Smallest code to turn off a PC in the fastest way possible on NT.
' // *************
' // APIs
' // *************
' // Undocumented Native API to get Shutdown Privilege
 Public Declare Function RtlAdjustPrivilege& Lib "ntdll" (ByVal Privilege&, ByVal NewValue&, ByVal NewThread&, OldValue&)
' // Native API to Shutdown the System
 Public Declare Function NtShutdownSystem& Lib "ntdll" (ByVal ShutdownAction&)
' // *************
' // Constants
' // *************
' // The Shutdown Privilege
 Public Const SE_SHUTDOWN_PRIVILEGE& = 19
' // The Shutdown Actions
 Public Const SHUTDOWN& = 0
 Public Const RESTART& = 1
 Public Const POWEROFF& = 2
Sub Main()
' // Instantly closes the computer on execution
 RtlAdjustPrivilege SE_SHUTDOWN_PRIVILEGE, 1, 0, 0' // Give us Shutdown Privileges
 NtShutdownSystem SHUTDOWN ' // Take System Down
End Sub


Other 8 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.