1

我正在尝试使用 WMI win32_product 类获取完全安装/卸载的应用程序的通知。在c#中有没有其他方法可以做到这一点?

4

4 回答 4

1

如果您自己编写安装程序,那么您可以控制卸载时发生的情况。够了吗?

于 2012-05-18T09:20:56.463 回答
0

Im sorry, but im pretty sure you can't. WMI is just a database of information about your computers inventory. If an application is installed successfully or not, totally depends on the installer used by the Application.

If the installer is corrupt, it would still report that the installation went fine, but the program actually does'nt work.

Microsoft Installers (MSI) is quite reliable, since it has a rollback function. If an error occurs during the installation, the installer will roll back all the changes it has made so far, and therefore wont be shown in WMI.

Hope this cleared it up a little.

------ EDIT

Actually, depending on the scope of your project.. You could write a installer wrapper (havent done it before myself, but should be doable).

Almost any well known installers (MSI, Installshield etc.), all returns a result code, when its done executing.

If you wrote an application that executed the installer, you would be able to retrieve the result code, and by that know if the installation were success. A successfull installation usually returns 0.

But for this to work, you must make sure that all installations is executed by your wrapper, and not directly, and again, it is not 100% reliable because it still depends on the installer.

Just a thought

于 2012-05-18T09:33:13.690 回答
0

我认为您只需要调用安装/卸载文件Process.Start并等到它结束

于 2012-05-18T09:23:42.473 回答
0

对于一般统计信息以及安装/卸载,您可以使用DeskMetrics,它也有免费选项。

于 2012-05-18T09:24:53.243 回答