November 25, 2020, 06:08:30 AM

Author Topic: [bb] Simple System Commands by Petron [ 1+ years ago ]  (Read 603 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Simple System Commands by Petron [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
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
  1. window=CreateWindow( "System",0,0,192,56,0,1 )
  2. button=CreateButton( "Turn Off",0,0,64,24,window )
  3. buttona=CreateButton( "Log Off",64,0,64,24,window )
  4. buttonb=CreateButton( "Restart",128,0,64,24,window )
  5. While WaitEvent()<>$803
  6. If EventID()=$401
  7. If EventSource()=button Then ExecFile("Shutdown.exe -s")
  8. If EventSource()=buttona Then ExecFile("Shutdown.exe -l")
  9. If EventSource()=buttonb Then ExecFile("Shutdown.exe -r")
  10. EndIf
  11. Wend
  12. 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)

 
Code: [Select]
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.
Code: [Select]
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


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal