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
John

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
        Close()
    End Sub
End Class

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.