CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2009
    Posts
    9

    Talking Start / stop services as standard user

    Hi again,

    I am trying to find a way to spawn a process that will continue running once I log off.
    A previous post ended up giving me a solution : services. I tried this out, and it solves
    the problem as it was stated - the service continues to run when I log off.

    However, I need Admin privileges to start / stop the service - which is not exactly the type of privileges my customers have.

    Any ideas ?


    Thanks

    Andy

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Start / stop services as standard user

    Start the service at boot up time, and let it run forever. Much like worker threads, program your service to sit idle, until a user logs in; launches a client program which will tell the service what to do; then the client can log out.

    Viggy

  3. #3
    Join Date
    May 2009
    Posts
    9

    Re: Start / stop services as standard user

    Thank you Viggy,

    I can install and start a service which will run forever.

    However, I'm not sure how to make this service spawn another process upon a user's request, and be sure this process will not be killed when the user logs off.

    Somewhere in the service I should have a call to ::CreateProcess (or similar), with something like ::CreateProcess(... "userexe.exe"...).

    How do I ensure that "userexe.exe" will not be killed when the user logs off ?

    Thank you again

    Andy

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Start / stop services as standard user

    I'm not familiar enough with Windows Services to answer your question, but can't you just have the service itself perform the work?

    Viggy

  5. #5
    Join Date
    Feb 2009
    Posts
    37

    Re: Start / stop services as standard user

    Any process your service starts will not be killed when the user logs off. Keep in mind though, you cannot start a process from the service that has a GUI unless you get the current logged on users token etc and use CreateProcessAsUser(); thus whatever process your service kicks off will run in Session 0 I believe it is.

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Start / stop services as standard user

    To run a process that is not designed to run service mode, with no user attendance, the user must use standard Switch User function but do not try to violate the very basic security principles.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured