Run a program before fully logging off

SpaceshipSpaceship
Watch

ralxz

Established Member
Impact
1
Hey guys. I'm looking to write a progam that would backup a directory before fully logging off. The ideal possibility would be: User Clicks Logoff -> Program Runs -> Logoff completes when program exits. Do you guys know how to interrupt a logoff like this?

Thanks,
Ryan
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Well if you run the command

shutdown -r

When you do the command to shutdown it stops the shutdown. It may work for logout try it and let me know how it works.

I know there is also something in register which you can edit that will pause or slow down logout. Allowing for a backup. I don't recommand banging around in registry but you can reasearch abit. Maybe take a look at the coding on time logouts. Like at the libary. See how they did it. Find a way to stop the logout and than run the program than set it to logout. Something like that :S

- Steve
 
Last edited:
0
•••
What code langauage? I have some code i found and modified for vb .net to recognize a logoff command and then write to a db table and then logoff.

Code:
Private Shared WM_QUERYENDSESSION As Integer = &H11
    Private Shared systemShutdown As Boolean = False
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = WM_QUERYENDSESSION Then
' Insert command to run here            
systemShutdown = True
        End If
        MyBase.WndProc(m)
    End Sub 'WndProc 

    Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        If (systemShutdown) Then
            systemShutdown = False
           e.Cancel = False
           End If
    End Sub
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back