Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

ExitWindowsEx

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ExitWindowsEx

    I have used the example "restart".

    function:
    ExitWindowsEx %EWX_LOGOFF OR %EWX_FORCE, 0

    I have remarked that it does not work with "runas". Even if the registered user has admin rights, the function does not work with "runas".

  • #2
    Windows NT/2000/XP: To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For more information, see Running with Special Privileges.
    (Code not shown.)
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I have used the followings code:

      http://www.powerbasic.com/support/pb...ad.php?t=24218

      RESTART works with "runas". Only LOGOFF does not work.

      I have built a setup for my program. The user must re-logon into the system at the end. (The restart lasts so long at Vista.)

      Problem only exists when the user starts the setup with "runas" as said, that. And, restart already works also with "runas".

      Is there a solution?

      Comment


      • #4
        Does the call to ExitWindowsEx succeed or fail? If it fails, what does GetLastError() tell you?

        (No , the posted code does not check the return)

        I'd also check on dwReason (parameter two) being zero.
        If this parameter is zero, the default is an undefined shutdown that is logged as "No title for this reason could be found". By default, it is also an unplanned shutdown. Depending on how the system is configured, an unplanned shutdown triggers the creation of a file that contains the system state information, which can delay shutdown. Therefore, do not use zero for this parameter. [Italics mine MCM]
        Last edited by Michael Mattias; 20 Dec 2007, 03:51 PM.
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Bernhard,
          I've tried the logoff code with RunAs under XP and have the same result as you do.

          I'm affraid to say that it's seem's normal behavior when using RunAs,
          here is what I have from my MSDN...

          "If the process calling ExitWindowsEx is in some other logon session,
          only the notifications are made; no processes are terminated."

          Comment


          • #6
            i have used this example (link above) to good success.
            It does reboot my Windows XP home fine

            How to modify this example for putting it in the standby (not sleep) modus?

            Thanks,
            hellobasic

            Comment


            • #7
              I know this is old but this just occurred to me ....

              Could it be that when you are "running AS" you are not actually logged on, so you have no need to log off?
              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment

              Working...
              X