Tuesday, March 20, 2012

Path to exe

I'm trying to automate opening the firewall for an instance of SQL.
For a given instance of SQL how do I find the path to the executable ?
I like to use Process Explorer from sysinternals (now acquired by MS). Just
mouse over the process name, and it'll show you the image path.
Now, if the instance is not running, this won't tell. But you can always
look into the registry under
HKLM\SYSTEM\CurrentControlSet\Services\MSSQLServer \ImagePath for teh default
instance and HKLM\SYSTEM\CurrentControlSet\Services\MSSQL$<inst ance
name>\ImagePath for a named instance.
Linchi
"Michael Tissington" wrote:

> I'm trying to automate opening the firewall for an instance of SQL.
> For a given instance of SQL how do I find the path to the executable ?
>
>
|||Hello Michael,
As Linchi has suggested, you can use the registry to find the certain SQL
Server instance/service's image path. Actually, the following registry
paths are the ones of SQL Server services.
HKLM\SYSTEM\CurrentControlSet\Services\MSSQLServer \ImagePath for teh
default
HKLM\SYSTEM\CurrentControlSet\Services\MSSQL$<inst ance name>\ImagePath
Therefore, in your code, you can loop through all those services and
checkout those ones that match the SQL server instances.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment