質問

C#カスタムアクション内からインストールした後、コンピューターの再起動を求めるにはどうすればよいですか?

セットアップにVS 2005のセットアッププロジェクトを使用しているため、プログラムで再起動を求めることを決定する必要があります(したがって、すべてのインストールでは発生しません。

更新:最初にMSIカスタムアクションシステムにすでに組み込まれているものを探しています。それが存在しない場合は、どういうわけか自分でPCを再起動することに頼ることができますが、それを避けたいと思います。

更新:ORCAでMSIを編集したときにReboot = Forceを設定できる場所がわかります。実行時にC#カスタムアクションからこれらのテーブルを変更できますか?これを毎回再起動するように設定できますが、セットアップが迷惑になる可能性があります(まれに再起動するだけです)。

更新:設定を試みました:

savedState["REBOOT"] = "Force";

カスタムアクションのインストール()メソッド内からですが、運はありません。 Idictionaryのようには見えませんが、SavedStateは本当に何でもします。

また試してみました:

Context.Parameters["REBOOT"] = "Force";

しかし、このコレクションは、カスタムアクションに渡されたコマンドラインの引数にすぎないと思います。

更新:このトリックを機能させるためにORCAでMSIを編集する方法はありますか?存在するファイルの条件で再起動をスケジュールしますか? C#カスタムアクションからMSIプロパティを設定する方法は見つかりませんでした。

更新:appdomain.processexitとappdomain.domainununloadに接続して、新しいスレッドを起動し、process.getCurrentProcess()を呼び出してみました。WaitForexit()。

役に立ちましたか?

解決 2

As it seems, the only way for us to solve this is to either:

A) Modify the MSI with orca to make the setup restart for every install

B) Redo the setup project with WiX or Install Shield

Thanks for the help guys.

他のヒント

You need to add or call the MSI custom action ScheduleReboot http://msdn.microsoft.com/en-us/library/aa371527(VS.85).aspx in your InstallExecuteSequence, . You can do this by using the MSI function MsiDoAction, http://msdn.microsoft.com/en-us/library/aa370090(VS.85).aspx inside a custom action. Please note that the custom action that schedules this must be an immediate custom action, not a deferred custom action. This means you will probably need to schedule it after InstallFinalize. You could also add it to the InstallExecuteSequence with a condition on a public property that your custom action sets.

When I've had to do this before we used a Win32 API function from user32.dll, I think this was it: ExitWindowsEx()

LanceSc has given you the answer. You need to run ScheduleReboot, and the best way to do so is to insert it in the InstallExecuteSequence conditioned by your own custom property that you set inside your custom action.

As you mention, Wix is the way to go for future flexibility. Wix now also includes DTF (Deployment Tools Foundation) which is a rich set of .NET class libraries that wrap the entire Windows API. You can use this to easily access MSI databases from C# or to write C# custom actions. I can provide more info on this if desirable.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top