Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? [modified]

MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
22 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kushagra Tiwari
    wrote on last edited by
    #1

    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

    H T D R 4 Replies Last reply
    0
    • K Kushagra Tiwari

      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

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      I'm not sure that WM_QUERYSESSION is sent to apps running in system account. You could try SetConsoleCtrlHandler() and catch the CTRL_SHUTDOWN_EVENT. I don't think this allows you to stop the shutdown.

      Best wishes, Hans


      [Hans Dietrich Software]

      K 1 Reply Last reply
      0
      • H Hans Dietrich

        I'm not sure that WM_QUERYSESSION is sent to apps running in system account. You could try SetConsoleCtrlHandler() and catch the CTRL_SHUTDOWN_EVENT. I don't think this allows you to stop the shutdown.

        Best wishes, Hans


        [Hans Dietrich Software]

        K Offline
        K Offline
        Kushagra Tiwari
        wrote on last edited by
        #3

        I got your point, but how do we use SetConsoleCtrlHandler in an MFC application..I can always do shutdown -a inside it if I recieve a CTRL_SHUTDOWN MEssage. Please Detail me how to include it in an MFC application ? Kushagra

        H 1 Reply Last reply
        0
        • K Kushagra Tiwari

          I got your point, but how do we use SetConsoleCtrlHandler in an MFC application..I can always do shutdown -a inside it if I recieve a CTRL_SHUTDOWN MEssage. Please Detail me how to include it in an MFC application ? Kushagra

          H Offline
          H Offline
          Hans Dietrich
          wrote on last edited by
          #4

          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


          [Hans Dietrich Software]

          K 1 Reply Last reply
          0
          • K Kushagra Tiwari

            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

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            It will sound funny, where actually are you catching WM_QUERYENDSESSION Message?

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
            Never mind - my own stupidity is the source of every "problem" - Mixture

            cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

            K 1 Reply Last reply
            0
            • T ThatsAlok

              It will sound funny, where actually are you catching WM_QUERYENDSESSION Message?

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
              Never mind - my own stupidity is the source of every "problem" - Mixture

              cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

              K Offline
              K Offline
              Kushagra Tiwari
              wrote on last edited by
              #6

              Hey Alok, I am trapping the message in WndProc(Windows Procedure Method) of the application. Then using the message handler for WM_QUERYENDSESSION I am returning false to abort logoff/shutdown and doing my functionality in between. Regards, Kushagra

              1 Reply Last reply
              0
              • H Hans Dietrich

                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


                [Hans Dietrich Software]

                K Offline
                K Offline
                Kushagra Tiwari
                wrote on last edited by
                #7

                Thanks Hans, But yes we can only intercept the message here and not abort shutdown here :( Kushagra

                1 Reply Last reply
                0
                • K Kushagra Tiwari

                  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

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  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

                  K 1 Reply Last reply
                  0
                  • D David Crow

                    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

                    K Offline
                    K Offline
                    Kushagra Tiwari
                    wrote on last edited by
                    #9

                    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

                    D 1 Reply Last reply
                    0
                    • K Kushagra Tiwari

                      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

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      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

                      R K 2 Replies Last reply
                      0
                      • D David Crow

                        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

                        R Offline
                        R Offline
                        Roger Stoltz
                        wrote on last edited by
                        #11

                        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

                        D 1 Reply Last reply
                        0
                        • D David Crow

                          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

                          K Offline
                          K Offline
                          Kushagra Tiwari
                          wrote on last edited by
                          #12

                          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

                          D 1 Reply Last reply
                          0
                          • R Roger Stoltz

                            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

                            D Offline
                            D Offline
                            David Crow
                            wrote on last edited by
                            #13

                            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

                            R 1 Reply Last reply
                            0
                            • K Kushagra Tiwari

                              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

                              D Offline
                              D Offline
                              David Crow
                              wrote on last edited by
                              #14

                              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

                              K 1 Reply Last reply
                              0
                              • D David Crow

                                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

                                K Offline
                                K Offline
                                Kushagra Tiwari
                                wrote on last edited by
                                #15

                                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

                                D 1 Reply Last reply
                                0
                                • D David Crow

                                  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

                                  R Offline
                                  R Offline
                                  Roger Stoltz
                                  wrote on last edited by
                                  #16

                                  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

                                  1 Reply Last reply
                                  0
                                  • K Kushagra Tiwari

                                    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

                                    D Offline
                                    D Offline
                                    David Crow
                                    wrote on last edited by
                                    #17

                                    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

                                    K 1 Reply Last reply
                                    0
                                    • D David Crow

                                      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

                                      K Offline
                                      K Offline
                                      Kushagra Tiwari
                                      wrote on last edited by
                                      #18

                                      I am afraid , I did not found any thing of such kind with an application running from System account. Kushagra

                                      K 1 Reply Last reply
                                      0
                                      • K Kushagra Tiwari

                                        I am afraid , I did not found any thing of such kind with an application running from System account. Kushagra

                                        K Offline
                                        K Offline
                                        Kushagra Tiwari
                                        wrote on last edited by
                                        #19

                                        Does anybody knows the solution ??? Kushagra

                                        D C 2 Replies Last reply
                                        0
                                        • K Kushagra Tiwari

                                          Does anybody knows the solution ??? Kushagra

                                          D Offline
                                          D Offline
                                          David Crow
                                          wrote on last edited by
                                          #20

                                          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

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups