Link to home
Start Free TrialLog in
Avatar of arumugaganesh
arumugaganesh

asked on

how to shut down a system(winNT/2000,98, 95)

hi experts,
            i would like to know how to shutdown or restart a system of win(2000 /NT/98/95), i need a coding in VB 6.0.thz in adv

Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi arumugaganesh,

http://www.btinternet.com/~vbadmincode/code/shutdown.zip

Is a sample application that allows you to initate a local or remote shutdown of a computer.

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com

ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And:

'In general section
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    msg = MsgBox("This program is going to reboot your computer. Press OK to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title)
    If msg = vbCancel Then End
    'reboot the computer
    ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
End Sub
Avatar of zfiexpert
zfiexpert

First declare this API:

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

Then in your code:

ExitWindowsEx EWX_REBOOT, 0
Unload Me

You can replace the EWX command with any of the following:

Ends Tasks = EWX_FORCE
Ends Tasks and then logs off = EWX_LOGOFF
Power off = EWX_SHUTDOWN
Reboot = EWX_REBOOT
ShutDown = EWX_SHUTDOWN

I hope I remembered everything. This one is a pain to test! If it works you still have to reboot! :)

Simplify.

-Shane
ZFi Enterprises
"I hope I remembered everything"
that was funny!
arumugaganesh:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Avatar of arumugaganesh

ASKER

hi ,
thank u all
regards
ganesh