home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Restart Button

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2075
Discussions: 200,973, Posts: 2,379,782, Members: 246,336
Old January 15th, 2003, 05:10 PM   Digg it!   #1 (permalink)
Member
 
Join Date: May 2002
Posts: 177
Restart Button

What would the code be in VB if I wanted to add a button to a program that would restart the computer. This would be in 2000 and XP if it makes a difference.

Thanks
J'rd is offline   Reply With Quote
Old January 15th, 2003, 11:25 PM     #2 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
ouch!

with or without user approval? and why?

as in you can follow the path that most winders OSes go through when after some action, OS wanna restart.

"Winders need to restart. Restart now? yes and no button"

"Winders need to restart. Restart now? ONLY yes button" no lose focus, restart or just look at screen.

If you don't know how to do this, maybe you shouldn't be....

Now, I have seen, and tried a DOS batch file, long ago.

I say tried, because it only worked on some PCs, and I don't have the code... wish I could find now.

Anyway, it sent the "reset" message to (most) mobos, and PC rebooted as if you had pressed Reset button on box. Good for malicious prank (run me and lose all work!).

why? do would you want to do this?
qball is offline   Reply With Quote
Old January 15th, 2003, 11:40 PM     #3 (permalink)
Member
 
Join Date: Feb 2002
Posts: 161
You will want to use the Win32 API function ExitWindowsEx(). Now because I have no idea how to call Win32 functions from VB, I did a quick Google search:

*********
Option Explicit

Declare Function ExitWindowsEx lib "user32" (ByVal uFlags As Long, _
ByVal dwReserved As Long) As Long

Const EWX_LOGOFF As Long = 0
Const EWX_SHUTDOWN As Long = 1
Const EWX_REBOOT = 2
Const EWX_FORCE As Long = 4
Const EWX_POWEROFF As Long = 8

'-- End --'

To use the code add this line where you wish to shut down Windows:

Dim sPar As Long
sPar = ExitWindowEx(command, &H0)
*********

Just stick something like that into a button's click event hander. And be careful!
Martee is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Charges against non-tippers dropped.. (8)
Is It Just Me? (3059)
The disrespect of Obama by Russian .. (48)
Delete an OS (16)
Nvidia GTX 260 problem (8)
Laptop with wireless problem. (12)
Wireless Televisions. (12)
CPU fan stops spinning randomly (11)
windows vista security holes (17)
Regular Build (11)
Point and Shoot Camera Suggestions. (7)
windows 7 problem (7)
Internet Lost (5)
Multiple Restarts Required at Boot (5)
Recent Discussions
Multiple Restarts Required at Boot (5)
Point and Shoot Camera Suggestions. (7)
Delete an OS (16)
cell phone won't work (0)
Nvidia GTX 260 problem (8)
Is the PSU I received dead? (15)
Can't open Word (12)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (37)
Steam ID's, Gamertags etc... (4)
Games, Cables, PCI cards, and more fo.. (6)
Dept. of HS: NSA 'Helped' Develop Vis.. (17)
Linksys WMP54GS wireless card problem.. (5)
windows vista security holes (17)
Help getting around port 80 for camer.. (5)
Skillsoft Network+ Study Software Que.. (10)
Browsers wont load websites (3)
help me pls laptop just stopped worki.. (0)
Open With ..... Win7 (3)
Laptop with wireless problem. (12)
Internet Lost (5)
virus blocking exe. files (1)
CPU fan stops spinning randomly (11)
Modern Warfare 2: Who Bought It? (65)
Print spooler problem (16)
Kingston Bluetooth Dongle Driver (1)


All times are GMT -4. The time now is 11:07 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28