Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    74
    Thanks
    0
    Thanked 1 Time in 1 Post

    Question Communication between running application and service [C++]

    Currently I have an application (A.exe) which determines when things need to be done, when such a time arises it launches another application (B.exe) with the appropriate parameters to do the actual work required, some of which could be administrative work (installing MSI, editing registry, etc...).

    This all works perfectly fine in an administrative environment - but soon the application will be migrated to a restricted (user) account where the running application (A) does not have the rights to launch application (B) to the necessary work. The solution, have an administrative service (service installed when logged on as admin during software installation), and have this service communicate between (A.exe) and (B.exe)... Let's call the service (C) ...

    My goal is therefore as follows:
    - (A.exe) tells (C) that something needs to be done (somehow)
    - (C) launches an instance of (B.exe) with admin rights (as it is an admin service) and (B.exe) performs the job just like it did before

    Now this raises a few questions I was hoping to get some feedback on from people who have encountered similar situations or have advice they could give me so I don't shoot myself in the foot :)

    1- My assumption is that I should be using C++ for my admin windows service, because C# requires all the managed DLLs and stuff I didn't want to risk any issues loading anything when running the admin service in a restricted user environment... am I crazy?

    2- What would be the best method of communication between (A.exe) and the service (C), I need to take into account the difference in security (admin vs user), would using POST MESSAGES (windows or not) and have (A.exe) "find by name" work, could I get handle to (C) when I am user and it is admin? I would like to not use the registry or a file (like a mailslot) to communicate between them - but I am not sure what the best approach would be.

    3- Will this actually work, if (C) launches (B.exe) does that imply that (B.exe) will have the admin rights it needs to perform its tasks?


    Any help or hints would be much appreciated - trying to get a good & proper design in place before I start coding ... any ideas or lessons-learned you could provide would be great.
    Thanks,

  • #2
    New Coder
    Join Date
    Jun 2006
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    I can't answer all of your questions, but I know it can be done. Just be careful in regards to OS. The various versions of Windows handle services and such differently. For instance, on Vista a service runs within a different session (session 0) than normal applications so there is some trickiness there in getting them to communicate and have the service kick off things. I know there is some "fun" stuff you need to do if you, for instance, want the service to run something that displays a GUI. If you run into trouble in that area, I can probably scrounge up some examples a fellow co-worker developed a few months back.

  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    74
    Thanks
    0
    Thanked 1 Time in 1 Post
    No GUI needed - (B.exe) is simply an application that does a job behind the scenese.

    So - is there a better approach that would be compatible with windows 2000, XP, and maybe Vista ... Using TCP to communicate for example?


  •  

    Posting Permissions

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