I’d like to access to assembly version information of a service I “control” with ServiceController class. (ie. I’d like to display “2.3.1.23” ), however I can’t find any information about retrieving assembly versions … Is it possible at all?
EDIT: Just to clarify … I only know the name of the service running on the local computer. I want to access the “FileVersionInfo” of that service (better said service exe), however I don’t know where is that service exe located.
If I understand you correctly, you want to get the version of any service exe. Assuming that you know the name and path of the service’s executable, you might want to try:
You can then use the properties of the
FileVersionInfoclass to show the version number. Please note that this also works for UNC paths as long as you have permissions to read-access the file.EDIT
To get the executable path and name if you only know the service name, you can access the Registry under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. Search a key that matches the service name. Under that key, there’s a value nameImagePaththat contains the executable’s name and path.