vs2005產生安裝程式時,想要加入一些動作,比如在安裝完成之後彈出一個視窗,或者在結束安裝後運行程式,這時需要使用CustomAction,具體操作參見
Vs2005安裝程式完成後,自動啟動程式 http://blog.hjenglish.com/optop/articles/1208387.html
How can I customize an MSI in the Visual Studio setup/deployment project? http://blogs.msdn.com/astebner/archive/2006/08/12/696833.aspx
最後產生了一個msi檔案,在xp下面下使用這個msi檔案安裝程式一切都正常,但是在win7下時,會報錯誤2869,<The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2869>
網上找了資料後,發現是 win7/vista的 UAC造成的,具體原因不再探究,下面是查到的解決方案,
Post-Build script to fix MSI issues in Vista for VS 2005 Setup and Deployment Projects
http://blog.csdn.net/sfz_roger/archive/2009/09/02/4508540.aspx
Solution for MSI Error 2869 on Windows Vista
http://blogs.x2line.com/al/archive/2007/07/20/3210.aspx
Windows installer error, Error Code : 2869. msidbCustomActionTypeNoImpersonate
http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/c1326233-3f10-4d98-96a7-4a22e5eeaa2d/
都說需要向 CustomActions添加屬性 msidbCustomActionTypeNoImpersonate,不過我沒找到直接添加的方式,
後來用了第三個方案就可以了
需要注意的是, 那個需要儲存的代碼最好儲存到 msi產生的目錄下,然後cscript NoImpersonate.vbs <msi-file>放到安裝項目的 PostBuildEvent事件中
BTW:下面這篇文章講了下關於與UAC有關的內容,覺得還不錯
讓您的應用程式更好地適應 Windows Vista 的使用者帳戶控制
http://msdn.microsoft.com/zh-cn/magazine/cc163486.aspx