|
-
Dec 2nd, 2003, 11:34 AM
#1
Thread Starter
New Member
How to call an exe on shut down
Hello everybody,
Does any one know how to call an exe on windows shut down.
Actually, while leaving the office every day we need to log off from one of our web site.
Some people forget logging off, hence needs some utility which will get fired on windows shut down.
Thanks
Pal
-
Dec 2nd, 2003, 01:39 PM
#2
Junior Member
Would a scheduled task would work?
-
Dec 3rd, 2003, 09:25 AM
#3
Frenzied Member
I dont quite understand your question.....whether u want to start program with windows startup? or start a program as windows shutsdown (not sure how this is possible.since windows wud shut the program off b4 completely shutting down)
so gerardofpr mite be correct...scheduled task ?
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Dec 3rd, 2003, 05:28 PM
#4
-
Dec 7th, 2003, 04:53 AM
#5
Fanatic Member
No, I dont think this can be done. Because once windows sends the SHUTDOWN notification it wont attemt to handle execution of applications anylonger and will shut down all current running programs during the OS shutdown process..
A website shouldn't require you to log off when you are done. Unless they are just trying to keep you safe by making sure you close an IE windows so it flushes the cookies the sites used. Otherwise if your shutting down your system then it really wouldnt matter, regardless...
-
Dec 12th, 2003, 12:06 AM
#6
Software Eng.
Originally posted by nkad
No, I dont think this can be done. Because once windows sends the SHUTDOWN notification it wont attemt to handle execution of applications anylonger and will shut down all current running programs during the OS shutdown process..
That's only during an emergancy or forced shutdown. For a regular shut down, Windows will send the proper messages to each application. (That's actually part of the reason why we have the shut down in the first place)
-
Dec 15th, 2003, 07:39 AM
#7
-
Dec 15th, 2003, 11:01 AM
#8
In WIndows XP, you can trap that message like said before, once you get that message execute a "shutdown -a" to abort the shutdown, run your programs and then shutdown the system
-
Dec 19th, 2003, 11:41 PM
#9
I wonder how many charact
Originally posted by Megatron
That's only during an emergancy or forced shutdown. For a regular shut down, Windows will send the proper messages to each application. (That's actually part of the reason why we have the shut down in the first place)
HA! Here's to a guy that helped me alot in my first forays into VB from Java!
Wondered if you disappeared or changed your username, but it appears you just don't visit the .Net forums.
-
Dec 25th, 2003, 07:04 PM
#10
Hyperactive Member
Originally posted by kasracer
In WIndows XP, you can trap that message like said before, once you get that message execute a "shutdown -a" to abort the shutdown, run your programs and then shutdown the system
Nice work....but three minor problems....
#1 - You'll have to have the host application constantly running (whther in the system tray, hidden, process or service....)
#2 - What's gonna happen when it tries to initialise the finishing shutdown sequence.....Won't it loop....
What I mean is this....
The OS tries to shut down... the program traps that and prevents it, it runs a sequence of events and when finished it shuts down the PC....
Won't it treat that new shutdown as a normal shutdown and repeat the processes?
#3 - The abort shutdown will only abort shutdown of the OS if it was that application that started the shutdown in the first place, else it would be ignored....
Plus, on a side note... if you tried that on WinXP, and presumably all other WinOSs, a message will popup saying that this program is not responding and after a certain time it will forcefully terminate the program....
So just make sure that whatever you are doing is done fast enough...
Sorry to be the kill joy, but I don't like to see people get happy over a pseudo~solution...
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
Dec 25th, 2003, 07:22 PM
#11
-
Dec 25th, 2003, 08:05 PM
#12
Hyperactive Member
Well that's 1 down.....2 left to go....
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
Dec 25th, 2003, 08:21 PM
#13
-
Dec 25th, 2003, 09:24 PM
#14
Hyperactive Member
I read yah @^
I guess that's not really a problem... so that makes 2 down....but we still have to solve the last one, and that one will prove to be the killer (no pun intended)
I was searching through the API Viewer and I saw this function:
VB Code:
Declare Function AbortSystemShutdown Lib "advapi32.dll" Alias "AbortSystemShutdownA" ( _
ByVal lpMachineName As String) As Long
I can't seem to get it to work.... anyone familiar with this function, and can help?
(P.S. When this thread gets resolved, I'll be the first to bookmark it....)
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
Dec 26th, 2003, 06:58 PM
#15
-
Dec 26th, 2003, 07:25 PM
#16
Addicted Member
-
Dec 26th, 2003, 08:05 PM
#17
Hyperactive Member
AbortSystemShutdown
The AbortSystemShutdown function stops a system shutdown started by using the InitiateSystemShutdown function.
Parameters:
lpMachineName
[in] Pointer to the null-terminated string that specifies the network name of the computer where the shutdown is to be stopped. If lpMachineName is NULL or an empty string, the function stops the shutdown on the local computer.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks:
The InitiateSystemShutdown and InitiateSystemShutdownEx functions display a dialog box that notifies the user that the system is shutting down. During the shutdown time-out period, the AbortSystemShutdown function can prevent the system from shutting down.
Abstract from the above link....
After reading that then I know for sure why I never got the function to work and why it would never succeed in this case....
So I guess this is hopeless and will remain unresolved....
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
Dec 26th, 2003, 08:28 PM
#18
-
Dec 26th, 2003, 08:50 PM
#19
Hyperactive Member
The AbortSystemShutdown function stops a system shutdown started by using the InitiateSystemShutdown function
The AbortSystemShutdown will only work if the system was shut down by using the InitiateSystemShutdown function...
Seeing the InitiateSystemShutdown is restricted to the application that called it, that makes it something like what kasracer said with the "shutdown - a" to abort...
Both cases will not work because it is restricted to the application that called it... Which means that if (example) Norton called the InitiateSystemShutdown after installing an update, then your application cannot AbortSystemShutdown to cancel out that effect.
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
-
Dec 26th, 2003, 09:15 PM
#20
Originally posted by Protocol
#1 - You'll have to have the host application constantly running (whther in the system tray, hidden, process or service....)
#2 - What's gonna happen when it tries to initialise the finishing shutdown sequence.....Won't it loop....
What I mean is this....
The OS tries to shut down... the program traps that and prevents it, it runs a sequence of events and when finished it shuts down the PC....
Won't it treat that new shutdown as a normal shutdown and repeat the processes?
#3 - The abort shutdown will only abort shutdown of the OS if it was that application that started the shutdown in the first place, else it would be ignored....
1. He is going to have to do that anyway. There is no magical API WhenShutDownOccursRunProgram(omg.exe)
2. It's called flags like already mentioned
3. I've used it before when programs have started a restart or shutdown after an update. Actually I've done it alot, and it always worked 
Originally posted by Protocol
Plus, on a side note... if you tried that on WinXP, and presumably all other WinOSs, a message will popup saying that this program is not responding and after a certain time it will forcefully terminate the program....
So just make sure that whatever you are doing is done fast enough...
Only if the system is shutting down. If you send shutdown -a to it, it won't do that. If a shutdown is initiated and isn't aborted, it stops the execution of code, you will have an almost impossible timeframe to use for the program.
I think the thread starter should just make a timeout for the server so when the connection is lost, after X minutes it disconnects/logs the user out. A client side program isn't really the solution for this sort of problem.
-
Dec 26th, 2003, 09:16 PM
#21
-
Dec 26th, 2003, 10:11 PM
#22
Hyperactive Member
kasracer:
I think the thread starter should just make a timeout for the server so when the connection is lost, after X minutes it disconnects/logs the user out. A client side program isn't really the solution for this sort of problem.
True that...I was thinking of that also...
P.S. I still can't get the "shutdown - a" to work...maybe it's just my PC.....
If my post has been helpful, then please rate it accordingly...
If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.
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
|