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
Printable View
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
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.
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
You can programmatically log off of windows.Quote:
Originally Posted by ian kerry
However, they would need to know to use your program to shutdown rather than what is built into the OS.
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?Quote:
Originally Posted by Atheist
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.Quote:
Originally Posted by Hack
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:
http://img152.imageshack.us/img152/4...shotra9.th.jpg
If that is the case, then it probably would work pretty well in XP.
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?
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.Quote:
Originally Posted by chris1990
It is VB6, though I have just downloaded 2008, but get all sorts of problem message about conversion.!Quote:
Originally Posted by Atheist
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
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.Quote:
Originally Posted by Atheist
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.Quote:
Originally Posted by ian kerry
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
Thanks, the queryUnload seems to do the job well.
Thanks all.
Ian
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!
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.
Have your program do the sync or not.
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
Didnt we answer this question already in the .NET Forum a while ago? It was the exact same question if memory serves me right.