Results 1 to 9 of 9

Thread: Restart Windows?

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    Restart Windows?

    Is there a function to just restart Windows, and not the whole computer?
    Alcohol & calculus don't mix.
    Never drink & derive.

  2. #2
    Matthew Gates
    Guest
    You could just crash explorer and this would force Windows to refresh/restart itself. I believe you can do this with the TerminateProcess API function.

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    here is some code that i wrote in VB, you got to convert it into C/C++/VC++

    VB Code:
    1. '// Main Form
    2. Private Sub cmdAction_Click()
    3.     If optShutdown(0).Value Then
    4.         Exit_Wnd 0
    5.     ElseIf optShutdown(1).Value Then
    6.         Exit_Wnd 1
    7.     ElseIf optShutdown(2).Value Then
    8.         Exit_Wnd 2
    9.     ElseIf optShutdown(3).Value Then
    10.         Exit_Wnd 3
    11.     End If
    12. End Sub
    13.  
    14. '// Basic Module
    15. Option Explicit
    16. '// WIN32API Function
    17. Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    18.  
    19. '// WIN32API Constant
    20. Const EWX_LOGOFF = 0
    21. Const EWX_SHUTDOWN = 1
    22. Const EWX_REBOOT = 2
    23. Const EWX_FORCE = 4
    24.  
    25. Public Sub Exit_Wnd(ByVal lpChoice As Integer)
    26.     Select Case lpChoice
    27.     Case 0
    28.         'Logoff
    29.         ExitWindowsEx EWX_FORCE Or EWX_LOGOFF, 0
    30.     Case 1
    31.         'ShutDown
    32.         ExitWindowsEx EWX_FORCE Or EWX_SHUTDOWN, 0
    33.     Case 2
    34.         'Reboot
    35.         ExitWindowsEx EWX_FORCE Or EWX_REBOOT, 0
    36.     Case 3
    37.         '???
    38.         ExitWindowsEx EWX_FORCE Or EWX_FORCE, 0
    39.     End Select
    40. End Sub
    regards,

  4. #4
    Megatron
    Guest
    Originally posted by Matthew Gates
    You could just crash explorer and this would force Windows to refresh/restart itself.
    LOL I don't think the user would be too fond of that.


    Wynd, you could use the ExitWindowsEx() function.
    Code:
    ExitWindowsEx(EWX_FORCE | EWX_REBOOT, 0);

  5. #5
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: Restart Windows?

    Just to restart Windows use:
    Code:
    ExitWindowsEx(EWX_LOGOFF, 0);

  6. #6

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Ok, thanks guys. The reason I asked is because lots of programs I've seen say "You must restart Windows to complete the installation" or something, but they restart the computer, not Windows.
    Alcohol & calculus don't mix.
    Never drink & derive.

  7. #7
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    But you don't have to necessarily restart the computer, a lot of the newer programs caught on to this, go into DOS for a few seconds, and come right back in.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  8. #8
    Megatron
    Guest
    One way is to hold shift while restarting. I don't know if you can programmatically simulate this though.

  9. #9
    Junior Member
    Join Date
    Aug 2001
    Location
    Israel
    Posts
    26
    Microsoft disabled the shift thingy in Windows ME and Win2K because some motherboards don't restart HDDs and FDDs right when you do it. It's better to restrt the wole computer
    Pinkfish Is NPC!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width