我的b/s结构软件升级包
2004-12-16 18:52
239 查看
从没看过别人如何写升级包,我想是不是能有这类的自动化工具?这个程序应该比较通用。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If CheckBox1.Checked = True Then
Dim dirinfo As DirectoryInfo = New DirectoryInfo(AppFolder.Text)
If dirinfo.Exists = False Then
MessageBox.Show("程序安装文件夹不存在,请重新填写.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
GoTo myFlagError
End If
Dim AppUpdate As New Process
AppUpdate.StartInfo.FileName = "xcopy.exe"
AppUpdate.StartInfo.Arguments = String.Format("{0} {1} /s /y", "App", AppFolder.Text)
Try
AppUpdate.Start()
AppUpdate.WaitForExit()
AppUpdate.Close()
MessageBox.Show("程序已经成功升级!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Catch ex As Exception
MessageBox.Show("升级程序失败!请联系北京****公司.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End Try
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If CheckBox2.Checked = True Then
Dim connString As String = String.Format("workstation id=.;packet size=4096;user id={0};pwd={1};data source=.;persist security info=False;initial catalog={2}", DBAdmin.Text, DBPasswd.Text, DBName.Text)
Try
Dim TestInteger As Integer = SqlHelper.ExecuteScalar(connString, CommandType.Text, "select count(*) from sysusers")
Catch ex As Exception
MessageBox.Show("数据库连接失败,请检查所填写数据库信息是否正确.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
GoTo myFlagError
End Try
Dim Succ As Boolean = True
Dim SQLUpdate As New Process
Dim files As FileInfo
Dim dir As DirectoryInfo = New DirectoryInfo("Sql/")
For Each files In dir.GetFiles
SQLUpdate.StartInfo.FileName = "osql.exe"
SQLUpdate.StartInfo.Arguments = String.Format("-U {0} -P {1} -d {2} -i {3}", DBAdmin.Text, DBPasswd.Text, DBName.Text, "Sql/" & files.Name)
Try
SQLUpdate.Start()
SQLUpdate.WaitForExit()
SQLUpdate.Close()
Catch ex As Exception
MessageBox.Show("升级数据库脚本 " & files.Name & " 失败!请联系北京****公司.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Succ = False
End Try
Next
If Succ = True Then
MessageBox.Show("数据库脚本已经成功升级!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End If
End If
myFlagError: ' 连接数据库失败出错!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If CheckBox1.Checked = True Then
Dim dirinfo As DirectoryInfo = New DirectoryInfo(AppFolder.Text)
If dirinfo.Exists = False Then
MessageBox.Show("程序安装文件夹不存在,请重新填写.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
GoTo myFlagError
End If
Dim AppUpdate As New Process
AppUpdate.StartInfo.FileName = "xcopy.exe"
AppUpdate.StartInfo.Arguments = String.Format("{0} {1} /s /y", "App", AppFolder.Text)
Try
AppUpdate.Start()
AppUpdate.WaitForExit()
AppUpdate.Close()
MessageBox.Show("程序已经成功升级!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Catch ex As Exception
MessageBox.Show("升级程序失败!请联系北京****公司.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End Try
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If CheckBox2.Checked = True Then
Dim connString As String = String.Format("workstation id=.;packet size=4096;user id={0};pwd={1};data source=.;persist security info=False;initial catalog={2}", DBAdmin.Text, DBPasswd.Text, DBName.Text)
Try
Dim TestInteger As Integer = SqlHelper.ExecuteScalar(connString, CommandType.Text, "select count(*) from sysusers")
Catch ex As Exception
MessageBox.Show("数据库连接失败,请检查所填写数据库信息是否正确.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
GoTo myFlagError
End Try
Dim Succ As Boolean = True
Dim SQLUpdate As New Process
Dim files As FileInfo
Dim dir As DirectoryInfo = New DirectoryInfo("Sql/")
For Each files In dir.GetFiles
SQLUpdate.StartInfo.FileName = "osql.exe"
SQLUpdate.StartInfo.Arguments = String.Format("-U {0} -P {1} -d {2} -i {3}", DBAdmin.Text, DBPasswd.Text, DBName.Text, "Sql/" & files.Name)
Try
SQLUpdate.Start()
SQLUpdate.WaitForExit()
SQLUpdate.Close()
Catch ex As Exception
MessageBox.Show("升级数据库脚本 " & files.Name & " 失败!请联系北京****公司.", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Succ = False
End Try
Next
If Succ = True Then
MessageBox.Show("数据库脚本已经成功升级!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End If
End If
myFlagError: ' 连接数据库失败出错!
相关文章推荐
- 关于软件自动升级程序的设计方法
- 实全软件产品自动升级管理解决方案
- 用C# 实现C/S模式下软件自动在线升级
- 用C# 实现C/S模式下软件自动在线升级【转】
- 用C#实现C/S模式下软件自动在线升级
- 功能强大的升级软件FREIA_jimyu,四步刷机法(更新EEP)
- 思科路由器系列软件安装与升级步骤 (1)
- 升级Ubuntu系统或者软件
- 软件升级- 私有部署应用程序升级策略
- VS制作软件安装项目,版本控制和软件升级
- 给Ubuntu软件升级命令
- 软件升级更新解决方案
- Bioconductor软件安装与升级
- “新IT”时代,传统软件企业你“升级”了吗?
- 在C#中实现软件自动升级(方法2)
- 让CentOS6 yum源支持更多rpm包的升级(使用第三方软件库EPEL、RPMForge与RPMFusion)
- 最强杀毒软件NOD32免费升级ID(保持最新)
- 8051单片机在线升级软件的方法
- [转]用C# 实现C/S模式下软件自动在线升级
- Linux 使用RPM安装卸载升级软件简介