升级整个publish目录的文件
xp系统需先按win+r运行一下 regsvr32.exe zipfldr.dll
需准备一下FTP服务器空间,然后在数据库中保存一下版本号以及升级规则,小升级的话用系统自带的升级,如果foxtable有版本更新,则可以用下面的升级方式
代码中的目录等可自行替换,我开发的系统要求用户都放在D盘下,大家不同目录的话可以在注册时将目录保存在注册表里面,然后在VBS脚本中读取目录
升级代码如下:
SysFTPClient.DownLoad("\WebSite\SysUpdate\进口商系统\进口商系统.zip","D:\进口商系统.zip",True)
If FileSys.FileExists("D:\进口商系统.zip") = False OrElse FileIO.FileSystem.GetFileInfo("D:\进口商系统.zip").Length = 0 Then Msgbox("升级文件下载失败,请重试!",64,"提示") : Return Nothing
Dim strCode As String = "'结束进程" & vbcrlf _
& "Set ws=createobject(""wscript.shell"")" & vbcrlf _
& "ws.run ""taskkill /f /im foxtable.exe"",hide" & vbcrlf _
& "Wscript.Sleep 1000" & vbCrlf _
& "'清理旧文件" & vbcrlf _
& "Set fso = CreateObject(""scripting.filesystemobject"")" & vbcrlf _
& "If fso.FolderExists(""d:\进口商系统" ") Then ws.Run ""cmd /c rd /s /q d:\进口商系统"",0" & vbCrlf _
& "'解压文件" & vbcrlf _
& "UnZip ""d:\进口商系统.zip"",""d:\进口商系统""" & vbcrlf _
& "fso.DeleteFile ""d:\进口商系统.zip"" " & vbCrlf _
& "Msgbox ""系统完整升级成功,点确定后将重新启动系统"",64,""提示"" " & vbCrlf _
& "Wsh.Run ""d:\进口商系统\进口商系统.exe"",1,false" & vbCrlf & vbCrlf _
& "Sub UnZip(ByVal ZipFile,ByVal TargetDir)" & vbcrlf _
& " Set fso = CreateObject(""Scripting.FileSystemObject"")" & vbcrlf _
& " If Not fso.FileExists(ZipFile) Then" & vbcrlf _
& " Exit Sub" & vbcrlf _
& " End If" & vbcrlf _
& " If Not fso.FolderExists(TargetDir) Then" & vbcrlf _
& " fso.CreateFolder(TargetDir)" & vbcrlf _
& " End If" & vbcrlf _
& " Set objShell = CreateObject(""Shell.Application"")" & vbcrlf _
& " Set objSource = objShell.NameSpace(ZipFile)" & vbcrlf _
& " Set objFolderItem = objSource.Items" & vbcrlf _
& " Set objTarget = objShell.NameSpace(TargetDir)" & vbcrlf _
& " objTarget.CopyHere objFolderItem,256" & vbcrlf _
& "End Sub"
FileSys.WriteAllText( environ("tmp") & "\UnZip.vbs" ,strCode,False,Encoding.Unicode)
Dim Proc As New Process
Proc.File = environ("tmp") & "\UnZip.vbs"
Proc.Start