|
-
Jan 31st, 2008, 05:43 AM
#1
Thread Starter
Junior Member
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
-
Jan 31st, 2008, 08:57 AM
#2
Hyperactive Member
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.
-
Jan 31st, 2008, 09:01 AM
#3
Thread Starter
Junior Member
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
-
Jan 31st, 2008, 10:20 AM
#4
Re: application to run before logout
 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.
-
Jan 31st, 2008, 10:43 AM
#5
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.
-
Jan 31st, 2008, 11:28 AM
#6
Re: application to run before logout
 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?
-
Jan 31st, 2008, 11:32 AM
#7
Re: application to run before logout
 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.
-
Feb 1st, 2008, 07:52 AM
#8
Re: application to run before logout
If that is the case, then it probably would work pretty well in XP.
-
Feb 1st, 2008, 02:47 PM
#9
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
-
Feb 3rd, 2008, 07:39 AM
#10
Hyperactive Member
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.
-
Feb 3rd, 2008, 09:06 AM
#11
Re: application to run before logout
 Originally Posted by chris1990
That would be a terrible solution. Not recommended at all.
-
Feb 4th, 2008, 05:25 AM
#12
Thread Starter
Junior Member
Re: application to run before logout
 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.!
-
Feb 4th, 2008, 05:29 AM
#13
Thread Starter
Junior Member
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
-
Feb 4th, 2008, 05:33 AM
#14
Re: application to run before logout
 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.
-
Feb 4th, 2008, 05:36 AM
#15
Re: application to run before logout
 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
-
Feb 4th, 2008, 09:49 AM
#16
Thread Starter
Junior Member
Re: application to run before logout
Thanks, the queryUnload seems to do the job well.
Thanks all.
Ian
-
Mar 27th, 2008, 10:34 PM
#17
New Member
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!
-
Mar 27th, 2008, 10:47 PM
#18
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.
-
Mar 27th, 2008, 10:48 PM
#19
Re: application to run before logout
Have your program do the sync or not.
-
Mar 27th, 2008, 10:56 PM
#20
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
-
Mar 27th, 2008, 11:39 PM
#21
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|