標籤:style blog http color os 使用 io ar 檔案
1. 提交階段,使用vbs調用mysql-connector-net-6.6.5.msi報錯
vbs 指令碼如下:
Dim retSet WshShell = WScript.CreateObject("WScript.Shell") ret = WshShell.Run("msiexec /i mysql-connector-net-6.6.5.msi")
解決方案:
開啟 %temp% 目錄,查看檔案名稱以msi開頭.log結尾的安裝錯誤記錄檔檔案(隨機名稱,如MSIeb1c8.LOG) ...win7預設就會產生該檔案,xp下據說需要設定點擊開啟連結
然後把上述代碼WScript.CreateObject....的WScript刪掉
Dim retSet WshShell = CreateObject("WScript.Shell") ret = WshShell.Run("msiexec /i mysql-connector-net-6.6.5.msi")
2. 安裝項目中的產生或提交階段 執行以下vbs, wshShell.Run strCmd死活執行不成功...原因可能是雖然install.exe和mysql-connector-net-6.6.5.msi檔案已經拷貝到安裝目錄了,但是這種狀態還未提交,因此指令碼還是找不到這兩個檔案
Dim wshShell,strPath, strPathTarget, strCmd, fso 'On error resume next Set wshShell = CreateObject("Wscript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") strPath = Session.Property("CustomActionData") &"install.exe" (install.exe即msiexec.exe) strPathTarget = Session.Property("CustomActionData") &"mysql-connector-net-6.6.5.msi" '這幾個引號那是相當煩,就是把整個語句包在一對引號中 strCmd = """"& strPath &" /i "& strPathTarget &"""" msgbox strCmd wshShell.Run strCmd ‘如果指令碼改以下,檔案路徑存在,則安裝包安裝成功。 wshShell.Run "E:\workstation\install.exe /i E:\workstation\mysql-connector-net-6.6.5.msi"
3. 變通的方法,把mysql-connector-net-6.6.5.msi拷貝到setup.exe/安裝包目錄下,就不打包到安裝包裡面了,使用者執行安裝包時,通過OriginalDataBase擷取安裝包路徑,從而找出mysql-connector的絕對路徑,然後執行之,WIN7下測試通過
Dim wshShell,strSetupMsiPath, strDir, strExecPath, strExecTarget, strCmd, fso 'On error resume next Set wshShell = CreateObject("Wscript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") 'CustomActionData is [OriginalDatabase] strSetupMsiPath = Session.Property("CustomActionData") strDir = GetDir(strSetupMsiPath, "MealBookerSetup.msi") strExecPath = strDir &"install.exe" strExecTarget = strDir &"mysql-connector-net-6.6.5.msi" strCmd = strExecPath &" /i "& strExecTarget (strCmd本身就是string,故程式碼片段2中這部分也是有問題的,應把兩邊的雙引號去掉) msgbox strCmd wshShell.Run strCmd 'wshShell.Run "msiexec.exe /i D:\Program Files\MealBooker\mysql-connector-net-6.6.5.msi" Private Function GetDir(fullpath, filename) dim pospos = 0pos = instr(fullpath, filename)if pos>0 then GetDir = left(fullpath, pos - 1)else GetDir = ""end if End Function
參考資料
.NET vs installer安裝項目失敗匯總