Search Tools Links Login

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

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 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.

Original Author: Ion Alex Ionescu


A closed PC.

Side Effects

Nothing will be saved, instant shutdown.

API Declarations



' // 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
' // 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

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 110 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.