How can I make it so that when i click on command1 it will shut down the computer, AND when i click command2 it will restart? And if you know how to log-off that would also be helpfull(Log off of your windows session)
ExitWindowsEx(EWX_REBOOT, 0) 'Reboots
ExitWindowsEx(EWX_LOGOFF, 0) 'Logs off
ExitWindowsEx(EWX_SHUTDOWN, 0) 'Shuts Down
ExitWindowsEx(EWX_FORCE or EWX_SHUTDOWN, 0) 'Forced shut down
[/vbcocde]
Originally posted by MartinLiss Your program won't be running after shut down so you can't do that.
I would think he would click Command2 instead of Command1.
eg. When you open up your start menu and click Shut Down Computer. You would get a pop up thing asking you what you want to do.
Originally posted by Psychotic I would think he would click Command2 instead of Command1.
eg. When you open up your start menu and click Shut Down Computer. You would get a pop up thing asking you what you want to do.
Perhaps you're right but lets's see what dabomb66 has to say since his/her question about Command2 specifically refers to restarting and not shuttting down.
Originally posted by MartinLiss Perhaps you're right but lets's see what dabomb66 has to say since his/her question about Command2 specifically refers to restarting and not shuttting down.
It does indeed specifically refer to restarting which would indicate that the computer is on. Otherwise you would just start up the computer....Click on the start menu and click Turn Off Computer. One of your options is to "Restart"
note that on NT systems, by default VB programs can't call ExitWindowsEx. you have to adjust the program's priviliges through code.. that function is included
the FORCE flag should be added to whatever action you are performing, if you want it forced
if you get stuck at the 'It is now safe to turn off your computer' screen, try using EWX_POWEROFF instead of EWX_SHUTDOWN
OK dude, well to shutdown the computer... ON WINDOWS XP ONLY... u enter:
VB Code:
shell("shutdown.exe")
or shellexecute("shutdown.exe") im not too sure since i dont use it much.
This hasen't worked for me and I believe it won't on XP, but will on older versions, since XP has more to just the shutdown.exe to shutdown. Itwould also make it a bit easier for a hacker to just put a shortcut to this in the startup folder
Use Shell ("C:\WINDOWS\system32\shutdown.exe -s"), as far as I know this works. To reboot instead, replace the "s" with "r". Again, not possitive if this code works yet, will test it in a while when I'm ready to shut down my computer. im 2 lazy 4 a reboot with all of my windows open and setup now.
Visit here to learn to make the VB interface fit you!.
"I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
"The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge