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#
  4. Run as system and logoff user "USER"

Run as system and logoff user "USER"

Scheduled Pinned Locked Moved C#
question
3 Posts 3 Posters 1 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.
  • S Offline
    S Offline
    SummerBulb
    wrote on last edited by
    #1

    Hi. I have a program that runs as a scheduled task. The program runs on XP as SYSTEM. The idea is that the program will run in the background, while USER is active. I need the program to logoff USER when specific conditions occur. I tried using

    [DllImport("user32.dll")]
    public static extern int ExitWindowsEx(int uFlags, int dwReason);

    but that appears to not log USER off. I think maybe it's logging SYSTEM off, as it is running as SYSTEM. How can i logogg USER? Thanks, SummerBulb.

    C S 2 Replies Last reply
    0
    • S SummerBulb

      Hi. I have a program that runs as a scheduled task. The program runs on XP as SYSTEM. The idea is that the program will run in the background, while USER is active. I need the program to logoff USER when specific conditions occur. I tried using

      [DllImport("user32.dll")]
      public static extern int ExitWindowsEx(int uFlags, int dwReason);

      but that appears to not log USER off. I think maybe it's logging SYSTEM off, as it is running as SYSTEM. How can i logogg USER? Thanks, SummerBulb.

      C Offline
      C Offline
      cor2879
      wrote on last edited by
      #2

      This MSDN thread appears to link to a possible solution for you: how to force the interactive user to logoff.

      "We are men of action; lies do not become us."

      1 Reply Last reply
      0
      • S SummerBulb

        Hi. I have a program that runs as a scheduled task. The program runs on XP as SYSTEM. The idea is that the program will run in the background, while USER is active. I need the program to logoff USER when specific conditions occur. I tried using

        [DllImport("user32.dll")]
        public static extern int ExitWindowsEx(int uFlags, int dwReason);

        but that appears to not log USER off. I think maybe it's logging SYSTEM off, as it is running as SYSTEM. How can i logogg USER? Thanks, SummerBulb.

        S Offline
        S Offline
        SimulationofSai
        wrote on last edited by
        #3

        You can also invoke shutdown.exe with the /l option. But I believe any logged on user gets a prompt saying that SYSTEM is trying to log off. I think is is so that any user can save his work prior to being logged off.

        SG Aham Brahmasmi!

        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