[bb] Simple System Commands by Petron [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:38

Previous topic - Next topic

BlitzBot

Title : Simple System Commands
Author : Petron
Posted : 1+ years ago

Description : Simple system commands restart, logoff, and shutdown.  The code is short but it does what is needed.  Enjoy

Code :
Code (blitzbasic) Select
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 :


Petron(Posted 1+ years ago)

 Blitz Plus only


SebHoll(Posted 1+ years ago)

 Windows XP only...


ShadowTurtle(Posted 1+ years ago)

 SP1 and higher only ...


Petron(Posted 1+ years ago)

 My Bad


Starwar(Posted 1+ years ago)

 Use shutdown.exe -a to stop the shutdown processwith shutdown.exe -t XX (XX = time in seconds) you can edit the countdowntime. With shutdown.exe -f you can kill applications.


ShadowTurtle(Posted 1+ years ago)

 
Repeat
  ExecFile("shutdown.exe -f");
Forever
h3h3 :=)


schilcote(Posted 1+ years ago)

 Make that copy itself into your startup folder, and you have a virus, my freind.


John Blackledge(Posted 1+ years ago)

 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