VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



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

by Ion Alex Ionescu (9 Submissions)
Category: Windows API Call/Explanation
Compatability: VB Script
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (7 Votes)

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.

Code Returns
A closed PC.
Side Effects
Nothing will be saved, instant shutdown.
API Declarations
RtlAdjustPrivileges
NtShutdownSystem

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

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

Download this snippet    Add to My Saved Code

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

No comments have been posted about Absolutely Fastest, Smallest Code to Shutdown a Windows NT/2000/XP Computer. Why not be the first to post a comment about Absolutely Fastest, Smallest Code to Shutdown a Windows NT/2000/XP Computer.

Post your comment

Subject:
Message:
0/1000 characters