SQLLocalDBがインストールされているかどうかをWiXで判断する方法を探しています。これどうやってするの?-レジストリキーを確認できますか?-はいの場合、どのキーですか?
7385 次
2 に答える
4
RegistrySearchはそれを行う必要があります:
<Property Id="LOCALDB">
<RegistrySearch Id="SearchForLocalDB" Root="HKLM"
Key="SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\CurrentVersion"
Name="CurrentVersion"
Type="raw" />
</Property>
それはあなたにバージョンを取得します。
于 2013-03-18T21:32:50.153 に答える
2
ユーザーがlocalDbをアンインストールした場合、レジストリエントリがまだ存在している可能性があるため、レジストリからのチェックが常に機能するとは限りません。
これが、コマンドラインからlocalDBのインストールを識別するために使用している関数です-
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;
}
于 2017-05-06T18:30:40.370 に答える