471,577 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,577 software developers and data experts.

"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 23586
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
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.