Code archives/Miscellaneous/Windows Shutdown

This code has been declared by its author to be Public Domain code.

Download source code

Windows Shutdown by pexe2004
use:
-s to shutdown
-r to restart
-l to logoff
and you can set the time to the operation by using -t XX
XX = time in secs

tested with Windows XP Professional
Function DLLShutdown(parm$="-s -t 0")
ExecFile SystemProperty("systemdir")+"shutdown.exe"+parm$
End Function

Comments

xlsior2004
You probably should parse your environment variables first, since you can never count on windows being installed in c:\windows... Many systems use c:\winnt instead, and technically it doesn't even have to be on your C drive.


pexe2004
it is only an example, you can custumize this code how you want..

and.. this conde only works with Windows XP


Chad2004
Kinda funny, should hide it somewhere in a program and if they press it, :-D


wizzlefish2005
Hmmm...I could make it automatically run when my sister gets on the computer and she'll only have 30 seconds...and in the last five seconds a skull comes up and yells "5...4...3...2...1!!" and then there's an explosion sound and the computer shuts down while the skull laughs maniacally!


Blaine2005
Instead of being:
Function DLLShutdown(parm$="-s -t 0",path$="C:")
ExecFile path$+"\WINDOWS\system32\shutdown.exe"+parm$
End Function

it should be:
Function DLLShutdown(parm$="-s -t 0")
ExecFile SystemProperty("systemdir")+"shutdown.exe"+parm$
End Function

Tested with XP. Should work on other versions of Windows as well.


Ked2006
I don't understand what to press to make it work....

_________________
Your just jealous because I'm human.


t3K|Mac2006
nice one for dealing with onlinecheaters ;)


xlsior2006
You can terminate the pending shutdown by doing a shutdown /a from the command line during the 30 second countdown.


t3K|Mac2006
most cheaters don't know that.


Ked2006
Thank you, thank you


Ked2006
For some reason this doesn't work on my computer. I ran it and nothing happened.


kevin80842006
try
api_ExitWindowsEx(5,0)



kfprimm2006
needs to be
Function DLLShutdown(parm$="-s -t 0")
ExecFile SystemProperty("systemdir")+"shutdown.exe "+parm$
End Function



pexe2011
BTW: I've fixed the code. Now it includes systemproperty ;)


BlitzSupport2011
Ha, welcome back!


*2011
With shutdown.exe you can do an instant shutdown so no chance of aborting it, used to do it on me step-sons computer he was prone to playing it till late so make his computer stay shutting down till 8am in the morning.


_PJ_2011
nice one for dealing with onlinecheaters ;)


Pretty sure there's some dodgy legal ground if your application initiates a shutdown procedure on someone's PC without their say-so.


Code Archives Forum