good morning,

I made a little VB app to shutdown a laptop after it has been powered on for 2 1/2 hours, and giving the user a little over 8min warning that it is about to be shutdown.
However I have nothing in place to stop the user from restarting the device once it is shutdown.
What I would like to integrate in this, is a sort of memory where if the user doesn't wait at least 30 minutes, the shutdwon will re-iniate immediatly.

May I request guidance? I included the code I did so far.

Thank you

Public Class Form1
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwmilliseconds As Long)

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

        'hides the form
        Me.Visible = False

        Sleep(9000000) '2 and 1/2 hours
        Shell("cmd /c shutdown -s -t 500 -f") '8:15min
    End Sub
End Class
6 Years
Discussion Span
Last Post by JohnPhilipps

May be you can store system shutdown time into registry or any other location and read the same on system start up. If the difference is < 30 mins call the shutdown routine again.


OK, so read the time value of the PC, store it, and have it read by the app upon startup.
Thanks for the tip,

I will try that approach

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.