How to programmatically find out where LocalDb is installed I'm writing a plugin for Cake Build tool where I need to start a LocalDB instance. But this code will be executed on different machines and LocalDB can be installed in different folders depending on the version of SQL Server installed in the build machine. 

I know at least 3 paths possible:

c:\Program Files\Microsoft SQL Server\130\Tools\Binn\SqlLocalDB.exe
C:\Program Files\Microsoft SQL Server\120\Tools\Binn\SqlLocalDB.exe
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SqlLocalDB.exe


Though I'm not absolutely sure about the last path. And I can't install SQL Server 2016 on my machine, so can't confirm if 

c:\Program Files\Microsoft SQL Server\140\Tools\Binn\SqlLocalDB.exe


would the correct guess.

I can iterate through a list of options and pick the one that works. 

Are there any other possible folder where SqlLocalDb.exe can be installed? 
Or is there a registry value somewhere that I can check?
Checking from the registry may not work all the time becasue if user uninstall the localDb then registry entries may still exist.

Here is the function I am using to identify the localDB installation from command line -

internal static bool IsLocalDBInstalled()
{
    // Start the child process.
    Process p = new Process();
    // Redirect the output stream of the child process.
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.FileName = "cmd.exe";
    p.StartInfo.Arguments = "/C sqllocaldb info";
    p.StartInfo.CreateNoWindow = true;
    p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    p.Start();
    // Do not wait for the child process to exit before
    // reading to the end of its redirected stream.
    // p.WaitForExit();
    // Read the output stream first and then wait.
    string sOutput = p.StandardOutput.ReadToEnd();
    p.WaitForExit();

    //If LocalDb is not installed then it will return that 'sqllocaldb' is not recognized as an internal or external command operable program or batch file.
    if (sOutput == null || sOutput.Trim().Length == 0 || sOutput.Contains("not recognized"))
        return false;
    if (sOutput.ToLower().Contains("mssqllocaldb")) //This is a defualt instance in local DB
        return true;
    return false;
}