プログラムのアンインストール時に services.msc スナップインを閉じるようユーザーに求める必要があります。それ、どうやったら出来るの?
1 に答える
0
そのためには、カスタム アクションを作成する必要があります。Processを使用して、services.msc が mmc に読み込まれているかどうかを確認できます。
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
foreach (Process getProcess in Process.GetProcesses())
{
if (getProcess.ProcessName.Contains("mmc"))
{
if (getProcess.MainWindowTitle == "Services")
{
session["SERVICES_MSC"] = "Running";
break;
}
}
}
return ActionResult.Success;
}
アンインストールでカスタム アクションを呼び出し、 SERVICES_MSCプロパティに基づいてアンインストールを停止します。
<Binary Id="Check_Services" SourceFile="..\TestProject\bin\Release\TestProject.CA.dll" />
<CustomAction Id="CHECK_SERVICES" BinaryKey="Check_Services" DllEntry="CustomAction1" Return="check" />
<CustomAction Id="STOP_INSTALLATION" Error="Services.msc is running.Please close that Window before uninstall the setup." />
Install Execute シーケンス内で、カスタム アクションを呼び出します。
<Custom Action="CHECK_SERVICES" After="InstallValidate">REMOVE ~= "ALL"</Custom>
<Custom Action="STOP_INSTALLATION" After="CHECK_SERVICES">(REMOVE ~= "ALL") AND SERVICES_MSC</Custom>
于 2013-06-07T13:24:41.527 に答える