|
-
Oct 31st, 2000, 05:04 AM
#1
Thread Starter
Junior Member
i have written an app that starts with windows as the shell.
the user then has to wait for it to restart windows.
how do i restart windows in the app?
can i use the api if the explorer shell was not loaded ?
i have tried the code below , but it just freezes the pc
Code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Sub Form_Load()
'this app gets called from my other app which started as
' the windows shell. When that app closes , then it calls
'this one to restart windows.
Sleep 3000
Label1.Caption = "Setting up Explorer..."
Name "c:\windows\explorer.exe" As "c:\windows\desklok.exe"
'rename my "explorer.exe" to "desklok.exe"
Sleep 500
Name "c:\windows\desklok.qaz" As "c:\windows\Explorer.exe"
'rename original "Explorer.exe" from "desklok.qaz"
Sleep 500
Label1.Caption = "Starting Windows..."
Sleep 500
Shell ("rundll user,exitwindowsexec")
'here it hangs
Sleep 2000
Unload Me
Set winex = Nothing
End
End Sub
plz can somebody help urgently
thankz
Go Luke , and may the source be with you.
-
Oct 31st, 2000, 05:39 AM
#2
Frenzied Member
This wil restart the computer:
Code:
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
ExitWindowsEx EWX_FORCE Or EWX_REBOOT, 0
-
Oct 31st, 2000, 06:02 AM
#3
Thread Starter
Junior Member
thanks , but how do i use it
i tried the code below but it gives an error that says
"Argument not optional"
Code:
exitwindowsex 2 ' 2 = restart windows
Go Luke , and may the source be with you.
-
Oct 31st, 2000, 07:02 AM
#4
Fanatic Member
You need that last parameter. This example is from http://www.vbapi.com.
Code:
' Reboot the computer, forcing any open programs to close
Dim retval As Long ' return value
retval = ExitWindowsEx(EWX_REBOOT Or EWX_FORCE, 0)
If retval = 0 Then Debug.Print "Reboot attempt failed."
I have tried this code before and have not been able to get it to re-boot, so something must still be missing. I am running NT. Does this code work for others out there ?
[Edited by jbart on 10-31-2000 at 07:04 AM]
-
Oct 31st, 2000, 07:12 AM
#5
Originally posted by railor
thanks , but how do i use it
i tried the code below but it gives an error that says
"Argument not optional"
Code:
exitwindowsex 2 ' 2 = restart windows
You are missing something.
exitwindowsex 2, 0
That's why you get the error.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|