.NET vs installer安装项目失败汇总
1. 提交阶段,使用vbs调用mysql-connector-net-6.6.5.msi报错
vbs 脚本如下:
Dim ret Set 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 ret Set 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 pos pos = 0 pos = instr(fullpath, filename) if pos>0 then GetDir = left(fullpath, pos - 1) else GetDir = "" end if End Function
参考资料
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。