dcsimg
Results 1 to 21 of 21

Thread: application to run before logout

  1. #1

    Thread Starter
    Junior Member ian kerry's Avatar
    Join Date
    Apr 2002
    Posts
    25

    application to run before logout

    Hi

    On my VBclockin programme I want my form to popup after someone has asked the computer to log them off. This will enable them to click the button "Clock Out".

    Is this possible?

    Thanks

    Ian

  2. #2
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Re: application to run before logout

    I dont think it can be done as when a user clicks log off it closes all running programs.
    You could change your program so it clocks out when someone logs off. You could use something like [cmdclockout.value = 1] on form unload.
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

  3. #3

    Thread Starter
    Junior Member ian kerry's Avatar
    Join Date
    Apr 2002
    Posts
    25

    Re: application to run before logout

    Hi Thanks for replying, I'll check that out. Can I do the opposite? Get the user to click clockout on the form, and then get the program to log off windows?

    Ian

  4. #4
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: application to run before logout

    Quote Originally Posted by ian kerry
    Hi Thanks for replying, I'll check that out. Can I do the opposite? Get the user to click clockout on the form, and then get the program to log off windows?
    You can programmatically log off of windows.

    However, they would need to know to use your program to shutdown rather than what is built into the OS.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,020

    Re: application to run before logout

    Is this VB6 or VB.Net?
    If it is VB.Net then you can simply add an eventhandler for the Microsoft.Win32.SystemEvents.SessionEnding event. In the eventhandler, set e.Cancel to true to cancel the logoff, do what you want, then programatically log out if needed.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  6. #6
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: application to run before logout

    Quote Originally Posted by Atheist
    Is this VB6 or VB.Net?
    If it is VB.Net then you can simply add an eventhandler for the Microsoft.Win32.SystemEvents.SessionEnding event. In the eventhandler, set e.Cancel to true to cancel the logoff, do what you want, then programatically log out if needed.
    So, if I have this app running, and minmizie the window, and then do Start/Logoff, this will catch it?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,020

    Re: application to run before logout

    Quote Originally Posted by Hack
    So, if I have this app running, and minmizie the window, and then do Start/Logoff, this will catch it?
    To be honest, I havent tried it, but it should work...I dont have alot to do right now so I think I'll try it and see if it works. I'll let you know how it went.

    Edit: Yeah, it seems to work, I tried canceling the logoff, and it worked alright. But after a couple of seconds, Windows (Vista) notifies the user that the application is canceling the logoff with this:
    Last edited by Atheist; Jan 31st, 2008 at 11:41 AM.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  8. #8
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: application to run before logout

    If that is the case, then it probably would work pretty well in XP.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: application to run before logout

    In VB6 you can just put the application (or a shell to it) in Form_QueryUnload, can't you? Or have I gone temporarily brain dead?
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  10. #10
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Re: application to run before logout

    you can hide the log off button from the start menu, using the registry. Look here, i dont know if this is the one you want but theres more on that site.

    http://www.pctools.com/guides/registry/detail/974/
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

  11. #11
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,020

    Re: application to run before logout

    Quote Originally Posted by chris1990
    you can hide the log off button from the start menu, using the registry. Look here, i dont know if this is the one you want but theres more on that site.

    http://www.pctools.com/guides/registry/detail/974/
    That would be a terrible solution. Not recommended at all.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  12. #12

    Thread Starter
    Junior Member ian kerry's Avatar
    Join Date
    Apr 2002
    Posts
    25

    Re: application to run before logout

    Quote Originally Posted by Atheist
    Is this VB6 or VB.Net?
    If it is VB.Net then you can simply add an eventhandler for the Microsoft.Win32.SystemEvents.SessionEnding event. In the eventhandler, set e.Cancel to true to cancel the logoff, do what you want, then programatically log out if needed.
    It is VB6, though I have just downloaded 2008, but get all sorts of problem message about conversion.!

  13. #13

    Thread Starter
    Junior Member ian kerry's Avatar
    Join Date
    Apr 2002
    Posts
    25

    Re: application to run before logout

    Hi All

    I think we have established that I can get users to use my form to log off - which i don't think will be a problem.

    I am currently using VB6, can some point me to the sort of code i would need to have a button that would save the time of the logoff and then log off windows?

    many thanks.

    ian

  14. #14
    Lurker
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: application to run before logout

    Quote Originally Posted by Atheist
    Edit: Yeah, it seems to work, I tried canceling the logoff, and it worked alright. But after a couple of seconds, Windows (Vista) notifies the user that the application is canceling the logoff with this:
    That dialogue is far too overzealous and is a design flaw in Vista. You'll notice it interferes with the shutdown process of Microsoft's own applications.

  15. #15
    Lurker
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: application to run before logout

    Quote Originally Posted by ian kerry
    Hi All

    I think we have established that I can get users to use my form to log off - which i don't think will be a problem.

    I am currently using VB6, can some point me to the sort of code i would need to have a button that would save the time of the logoff and then log off windows?

    many thanks.

    ian
    There is no need to programmatically log off. As a rule of thumb, anything that requires the user to change how they interact with the OS in order to facilitate your application is bad design.

    Instead, simply trap the QueryUnload event of your application's main form.
    This event is specifically designed exactly for your purpose, and even provides the shutdown reason as an argument.


    Moved from General PC

  16. #16

    Thread Starter
    Junior Member ian kerry's Avatar
    Join Date
    Apr 2002
    Posts
    25

    Re: application to run before logout

    Thanks, the queryUnload seems to do the job well.

    Thanks all.

    Ian

  17. #17
    New Member
    Join Date
    Mar 2008
    Posts
    1

    Re: application to run before logout

    Let me begin by saying that I know EXTREMELY little about coding and vbs.

    I found this forum because I'm searching for what I think is a simple solution, and I'm hoping you all will entertain my question since it relates to this topic.

    When I click shutdown in Windows XP, I want a dialog box to pop up that says, "Have You Synced?" and then has a "yes" and "no". If I click "no" then I return to desktop, if I click "yes" then the computer continues to shut down.

    Is that possible? I figured out how to get .vbs scripts to run at logoff/logon and shutdown/startup but when I run at shutdown, the message doesnt pop up until right before the computer shuts down and I'll probably have left the computer by then.

    When I run it at logoff, windows just continues through its shutdown cycle and ignores the fact that I have not clicked ok.

    I need some kind of code that would allow me to tell windows to STOP!. Even if I cant get the "yes" "no", if I could just get windows to pop up a message and stop the shutdown process, I would realize I forgot to sync and start the computer back up to sync.

    If all that rambling means nothing, perhaps my reason might make it clearer. I have a server where I save my files by syncing the files. Occasionally I forget to sync and then when I get to my other location I dont have access to files.

    Thanks in advance!

  18. #18
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,597

    Re: application to run before logout

    Welcome to the forums. In the future you may want to start your own thread vs piggybacking on someone elses.

    Anyway I found your question intriguing & my first guess was wrong, but second appears correct & found an example that may help. However, I don't know if it can be done in VBS. But it can be done by creating a little stand alone app that you have run on windows startup. It will require subclassing and the link/example can be found here. Once on that link, search the page for Kasia & look at all replies by that person.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  19. #19
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: application to run before logout

    Have your program do the sync or not.

  20. #20
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,597

    Re: application to run before logout

    Here is some MSDN documentation pertaining to the 2 messages to be intercepted in the subclassing procedure. See link in post #18 above.
    WM_QUERYENDSESSION & WM_ENDSESSION
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  21. #21
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,698

    Re: application to run before logout

    Didnt we answer this question already in the .NET Forum a while ago? It was the exact same question if memory serves me right.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width