Code archives/BlitzPlus Gui/Simple System Commands
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
Simple system commands restart, logoff, and shutdown. The code is short but it does what is needed. Enjoy | |||||
window=CreateWindow( "System",0,0,192,56,0,1 ) button=CreateButton( "Turn Off",0,0,64,24,window ) buttona=CreateButton( "Log Off",64,0,64,24,window ) buttonb=CreateButton( "Restart",128,0,64,24,window ) While WaitEvent()<>$803 If EventID()=$401 If EventSource()=button Then ExecFile("Shutdown.exe -s") If EventSource()=buttona Then ExecFile("Shutdown.exe -l") If EventSource()=buttonb Then ExecFile("Shutdown.exe -r") EndIf Wend End |
Comments
| ||
Blitz Plus only |
| ||
Windows XP only... |
| ||
SP1 and higher only ... |
| ||
My Bad |
| ||
Use shutdown.exe -a to stop the shutdown process with shutdown.exe -t XX (XX = time in seconds) you can edit the countdowntime. With shutdown.exe -f you can kill applications. |
| ||
Repeat ExecFile("shutdown.exe -f"); Forever h3h3 :=) |
| ||
Make that copy itself into your startup folder, and you have a virus, my freind. |
| ||
Many years later..... This still works with Windows 7, but I also use the -t 0 parameters for immediate no-quibble reaction. window=CreateWindow( "System",0,0,240,56,0,1 ) btnLogOff =CreateButton( "Log Off", 0,0,80,24,window ) btnReboot =CreateButton( "Reboot", 80,0,80,24,window ) btnShutDown=CreateButton( "Shut Down",160,0,80,24,window ) While WaitEvent()<>$803 If EventID()=$401 If EventSource()=btnLogOff Then ExecFile("Shutdown.exe -l -t 0") If EventSource()=btnReboot Then ExecFile("Shutdown.exe -r -t 0") If EventSource()=btnShutDown Then ExecFile("Shutdown.exe -s -t 0") EndIf Wend End |
Code Archives Forum