码迷,mamicode.com
首页 > Web开发 > 详细

.NET vs installer安装项目失败汇总

时间:2014-08-29 18:18:18      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   使用   io   ar   文件   

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") 

bubuko.com,布布扣

解决方案:

打开 %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

参考资料









.NET vs installer安装项目失败汇总

标签:style   blog   http   color   os   使用   io   ar   文件   

原文地址:http://blog.csdn.net/shineych/article/details/38921105

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!