Windows Shutdown

Ford Prefect 20 Reputation points
2025-07-11T09:59:41.2133333+00:00

I have a small app written in .NET 9, VB.

The app does use an xml data file.

When shutting down the computer, this app prevents windows from shutting down to allow user to save work.

This is despite the fact that NO data saving is required at the time of shutdown.

All this overkill is so ridiculous and without a way to deal with it as far as I can find.

Is there any way to shutdown WITHOUT this annoyance? An unattended shutdown is impossible the way it is.

Developer technologies | VB
{count} votes

1 answer

Sort by: Most helpful
  1. Ford Prefect 20 Reputation points
    2025-07-28T12:21:17.4333333+00:00

    Hi

    vb .net 9, Forms app, Windows 11 fully updated.

    Just for completeness, here is the solution I found. It works just as I wanted, no fuss, no cuss.

    I found that all Forms require this Sub, if any do not have it then it seems it will not do the job.

    As I run multiple instances of this app (actually just 2, 1 on each of 2 Surface Pros), I can confirm this works fine.

    ' This code required on every Form (as far as I can determine).

    Private Const WM_QUERYENDSESSION As Integer = &H11
    Protected Overrides Sub WndProc(ByRef m As Message)
    	If m.Msg = WM_QUERYENDSESSION Then
    		m.Result = CType(1, IntPtr)			Return
    	End If
    MyBase.WndProc(m)
    End Sub
    
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.