Question

I want to log out my computer with delay in a vbscript. Here is what i've tried so far:

Dim ObjShell
Set ObjShell = CreateObject("WScript.Shell")
ObjShell = msgbox("Wollen Sie den Computer herunterfahren ?", +vbYesNo+vbExclamation, "")
If ObjShell = 6 then
Set ShellObject = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each sys In ShellObject
Sys.Win32Shutdown 0
Next
End if

I do want to know how i can create a delay.

Was it helpful?

Solution

You can use WScript.Exec "shutdown.exe -L -F -t 30" to let the waiting be done by shutdown or use Wscript.Sleep 30000 to initiate a wait before the next statement is executed.

Both times are 30 seconds in this example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top