locked
Windows shutdown timing RRS feed

  • Question

  •  

    Imports Microsoft.Win32

    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\TimerShutDown", "TimerShutDown", "C:\ProgramFiles\VSoft\TimerShutDown.exe")

    Shell("shutdown -s -t 120")

    End Sub

    End Class

     

    1. Why does Windows not wait 120 sec before initiate shutdown? 2. How could several hours waiting time before shutdown coded?

    Wednesday, February 13, 2008 2:59 AM

Answers

  • the "-t" option specifies a timeout value, not a wait value.  In other words, if the shutdown cannot complete in 2 minutes it will fail.  If you want to wait 2 minutes before shutting down, do this:

    System.Threading.Thread.Sleep(120000)

    Shell("shutdown -s")

     

    Wednesday, February 13, 2008 1:28 PM