MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? [modified]
-
The MSDN article has a link at the bottom to an example. It's not MFC, but you should be able to use it in an MFC app.
Best wishes, Hans
Thanks Hans, But yes we can only intercept the message here and not abort shutdown here :( Kushagra
-
Hello all, I have made an MFC application with invisible window and invisible in Applications tab of taskmanager designed to run in different sessions depending upon the number of users who are logged into the system. Thus, according to user events the instances used to capture logoff/Shutdown/Logon events for that particular session.Also, I have made one instance of this executable to run in 'SYSTEM' account to capture scheduled shutdown in cases when no user was logged on the machine. However in this case 'WM_QUERYENDSESSION' is never recieved by this running instance of my application which runs in 'SYSTEM' account.Can some one tell me how to abort scheduled shutdown in Windows from an application running in system account , in a case when no user is logged on in the machine. Regards, Kushagra I hate coding but I luv to develop :)
modified on Wednesday, October 21, 2009 9:22 AM
Kushagra Tiwari wrote:
However in this case 'WM_QUERYSESSION' is never recieved by this running instance...
Where is this message being sent from? Is that process sending it to your window directly, or to all top-level windows via
HWND_BROADCAST
?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Kushagra Tiwari wrote:
However in this case 'WM_QUERYSESSION' is never recieved by this running instance...
Where is this message being sent from? Is that process sending it to your window directly, or to all top-level windows via
HWND_BROADCAST
?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
Hello David, Generally when windows receives shutdown event it broadcasts WM_QUERYENDSESSION to all top level windows applications , here the issue is as my MFC application is running silently from 'System' account somehow the broadcasted message from Windows is not able to identify this as a Top level windows application.Hence, this application never recives the message whcih is why I am stuck here. All i need to do is to stop scheduled shutdown from a process running in 'System' account. I am open to suggestions , if this can be done in any other way too. Regards, Kushagra
-
Hello David, Generally when windows receives shutdown event it broadcasts WM_QUERYENDSESSION to all top level windows applications , here the issue is as my MFC application is running silently from 'System' account somehow the broadcasted message from Windows is not able to identify this as a Top level windows application.Hence, this application never recives the message whcih is why I am stuck here. All i need to do is to stop scheduled shutdown from a process running in 'System' account. I am open to suggestions , if this can be done in any other way too. Regards, Kushagra
Kushagra Tiwari wrote:
Generally when windows receives shutdown event it broadcasts WM_QUERYENDSESSION to all top level windows applications...
I'm very familar with all of this. I was inquiring about the
WM_QUERYSESSION
message."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Kushagra Tiwari wrote:
Generally when windows receives shutdown event it broadcasts WM_QUERYENDSESSION to all top level windows applications...
I'm very familar with all of this. I was inquiring about the
WM_QUERYSESSION
message."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
DavidCrow wrote:
I was inquiring about the WM_QUERYSESSION message
Most likely a typo since the heading of the post says
WM_QUERYENDSESSION
, don't you think? :-\"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
Kushagra Tiwari wrote:
Generally when windows receives shutdown event it broadcasts WM_QUERYENDSESSION to all top level windows applications...
I'm very familar with all of this. I was inquiring about the
WM_QUERYSESSION
message."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
Hey David, I am sorry It was a TYPO from my side :confused: . But kindly suggest some way so that I can achieve my goal. Kushagra
-
DavidCrow wrote:
I was inquiring about the WM_QUERYSESSION message
Most likely a typo since the heading of the post says
WM_QUERYENDSESSION
, don't you think? :-\"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknownOne can choose to make assumptions, or not. I've been around long enough to know that folks don't always ask the right question.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Hey David, I am sorry It was a TYPO from my side :confused: . But kindly suggest some way so that I can achieve my goal. Kushagra
Kushagra Tiwari wrote:
But kindly suggest some way so that I can achieve my goal.
Do you receive the message if the window is visible? What about if it's running in a non-SYSTEM account?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Kushagra Tiwari wrote:
But kindly suggest some way so that I can achieve my goal.
Do you receive the message if the window is visible? What about if it's running in a non-SYSTEM account?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
I have made it invisible , and I recieve this message for all accounts other than SYSTEM account and they are working pretty neat , but only for this particular case for monitering scheduled shutdowns through system account my logic goes for a toss as the message WM_QUERYENDSESSION never comes to the application. Kushagra
-
One can choose to make assumptions, or not. I've been around long enough to know that folks don't always ask the right question.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
DavidCrow wrote:
I've been around long enough to know that folks don't always ask the right question.
I'm well aware of that and you are not the only one. For the record my post wasn't meant as criticism as you seem to have understood it.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
I have made it invisible , and I recieve this message for all accounts other than SYSTEM account and they are working pretty neat , but only for this particular case for monitering scheduled shutdowns through system account my logic goes for a toss as the message WM_QUERYENDSESSION never comes to the application. Kushagra
With services, there is the "Allow service to interact with desktop" option. Is there a similar option for an app running as the SYSTEM account?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
With services, there is the "Allow service to interact with desktop" option. Is there a similar option for an app running as the SYSTEM account?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
I am afraid , I did not found any thing of such kind with an application running from System account. Kushagra
-
I am afraid , I did not found any thing of such kind with an application running from System account. Kushagra
Does anybody knows the solution ??? Kushagra
-
Does anybody knows the solution ??? Kushagra
You might want to also pose this question to the folks in the microsoft.public.vc.language newsgroup. Several sharp folks are active there.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Does anybody knows the solution ??? Kushagra
From MSDN: "Console applications receive shutdown notifications in their handler routines. To register a console handler, use the SetConsoleCtrlHandler function. Service applications receive shutdown notifications in their handler routines. To register a service control handler, use the RegisterServiceCtrlHandlerEx function." Maybe that helps.
-
Hello all, I have made an MFC application with invisible window and invisible in Applications tab of taskmanager designed to run in different sessions depending upon the number of users who are logged into the system. Thus, according to user events the instances used to capture logoff/Shutdown/Logon events for that particular session.Also, I have made one instance of this executable to run in 'SYSTEM' account to capture scheduled shutdown in cases when no user was logged on the machine. However in this case 'WM_QUERYENDSESSION' is never recieved by this running instance of my application which runs in 'SYSTEM' account.Can some one tell me how to abort scheduled shutdown in Windows from an application running in system account , in a case when no user is logged on in the machine. Regards, Kushagra I hate coding but I luv to develop :)
modified on Wednesday, October 21, 2009 9:22 AM
Kushagra Tiwari wrote:
I have made an MFC application with invisible window and invisible in Applications tab of taskmanager .... I have made one instance of this executable to run in 'SYSTEM' account
Does this mean that you have created a service?
Kushagra Tiwari wrote:
how to abort scheduled shutdown in Windows from an application running in system account
Are you certain that you really want to do this even if it's possible? What do you mean by 'scheduled'? Personally I find it suspicious that you have created an application that runs "invisible" from user perspective that aims to block the system from being brought down. I would consider it to be a very anti-social application that I wouldn't want running on any of my machines. However, if an application calls
::ExitWindowsEx()
with theEWK_FORCE
parameter,WM_QUERYENDSESSION
will not be sent - all processes will be terminated and possibly with data lost. How do you distinguish from a 'scheduled' shutdown and one triggered by a user in your message handler or callback? I guess the user won't be able to bring the system down either.... What if your application runs on a machine with UPS; the power is lost and the UPS service wants to bring the system down safely? Will you block it if possible? I guess my question really is "what are to trying to accomplish and why"? There may be a better solution."It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown