469,306 Members | 1,794 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

"path to executable" of a windows service from a c# application

Hello,

how can I get the "path to executable" of a windows service from a c#
application ?

I have tried the ServiceContoller class, ServiceBase class with no
results...

Thanks,

Dec 27 '05 #1
4 23448
Path.GetFileName(Assembly.GetExecutingAssembly().G etName().CodeBase))

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp

<je******************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hello,

how can I get the "path to executable" of a windows service from a c#
application ?

I have tried the ServiceContoller class, ServiceBase class with no
results...

Thanks,

Dec 27 '05 #2
Hi, thanks...but I can use it because it is not my service...I don't
have the code...I want to get the "path to executable" of a windows
service from ANOTHER c# application

Dec 27 '05 #3
The information is stored in the registry key
HKLM\System\CurrentControlSet\Services\<%serviceNa me%>\ImagePath
contains the name of the executable including the full path.

Use the Microsoft.Win32.RegistryKey class to read this value which can
then split using GetDirectoryName to get the path.

Dec 28 '05 #4
Thanks!!! that worked!!!

Dec 28 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by awan | last post: by
1 post views Thread by DotNetJunkies User | last post: by
1 post views Thread by Winterminute | last post: by
reply views Thread by dsh | last post: by
9 posts views Thread by Clinton Frankland | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.