Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Location
    Tananger, Norway
    Posts
    1,461

    Get target file for a Windows Service?

    I need to get which .exe file that a Windows Service is pointing at using C#. The name of the service comes from userinput and then the user can if he wants to delete the Service. However I want to logg what is beeing deleted so that if the user deletes the wrong service I could always recreate the service for him. I've gotten the Service Name, Display Name and so on out already with the ServiceController class, but I can't seem to find anywhere where it says that I can get the target file for the service?

  2. #2
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    Hmm, see if this was win32, Id be telling you to use the registry, all thats there.. (HKLM/System/CurrentControlSet/Services) but, I dont see a c# one to tell you the exe and starup parameters
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  3. #3
    Join Date
    Dec 2003
    Location
    Tananger, Norway
    Posts
    1,461
    Well, I guess I could always read the registry. Was hoping that there was a Property of some builtin "thingy" in either C# or .Net 3.5 that could do this for me.

    Do you know if the path to where in the registry the services are stored would be the same for x86 and x64, and if it's the same for XP, Vista, Server 2003/2008 (I can always test this myself, but if someone already knows the answer :-)?

  4. #4
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    Its certainly the same on 2003 and vista, so most likely is the same on 2008, as for 64 and 32? shrug, probably but someone with it to hand would be best to answer
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  5. #5
    Join Date
    Dec 2003
    Location
    Tananger, Norway
    Posts
    1,461
    Thanks for the help LizRiley

    As far as I can tell this seems to be one of the few places where microsoft has been consistent. So it appares to be the same location in the registry for anything above windows 2k.

Posting Permissions

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