Dim upathPub As String
If FileSys.FileExists(ProjectPath & "狐表实验.FOXDB.BAK") = True Then
Return Nothing
Else
upathPub = ProjectPath.SubString(0,ProjectPath.length-8)
End If
Dim s As String = upathPub & "\鲜迪狐表.bat"
Dim s1 As String = ProjectPath & "\附件\Foxtable.IO.zip"
Dim s2 As String = ProjectPath & "\附件\Foxtable.Io.dll"
If FileSys.FileExists(s) Then
FileSys.DeleteFile(s)
End If
Dim DR As String = upathPub & "\Foxtable.Io.dll"
FileSys.WriteAllText(s,"@echo off" & vbcrlf,True,Encoding.Default)
FileSys.WriteAllText(s,"@title 正在关闭狐表项目..." & vbcrlf,True,Encoding.Default)
'FileSys.WriteAllText(s,"taskkill /f /im foxtable.exe" & vbcrlf,True,Encoding.Default)
'FileSys.WriteAllText(s,"taskkill /f /im 鲜迪外网.exe" & vbcrlf,True,Encoding.Default)
'FileSys.WriteAllText(s,"taskkill /f /im 鲜迪狐表.exe" & vbcrlf,True,Encoding.Default)
FileSys.WriteAllText(s,"@cls" & vbcrlf,True,Encoding.Default) '清除屏幕.清除删除 foxtable.exe 进程后屏幕反馈的信息.
FileSys.WriteAllText(s,"echo Wscript.Sleep Wscript.Arguments(0) * 1000>Delay.vbs" & vbcrlf,True,Encoding.Default)
FileSys.WriteAllText(s,"Delay.vbs 3" & vbcrlf,True,Encoding.Default)
FileSys.WriteAllText(s,"del Delay.vbs" & vbcrlf,True,Encoding.Default)
FileSys.WriteAllText(s,"Winrar x " & S1 & " " & "-y" & vbcrlf,True,Encoding.Default) '解压缩文件
FileSys.WriteAllText(s,"del /q /f " & DR & vbcrlf,True,Encoding.Default) '删除文件
'FileSys.WriteAllText(s,"copy /D /y " & S2 & " " & dr & vbcrlf,True,Encoding.Default) '复制文件
'FileSys.WriteAllText(s,"del /q /f " & s2 & vbcrlf,True,Encoding.Default) '删除文件
FileSys.WriteAllText(s,"@cls" & vbcrlf,True,Encoding.Default) '清除屏幕反馈的信息.
Dim Proc As New Process '定义一个新的Process
Proc.File = s '指定要打开的文件
Proc.Verb = "Open" '指定动作
Proc.Start()
proc.WaitForExit
老大:上述代码是想在发布项目万一无法启动时,将附件中Foxtable.IO.zip压缩文件先解压后,覆盖项目中的Foxtable.Io.dll文件(经实验这样以后可以正常启动项目),保证项目正常运行。想把这些命令生成“鲜迪狐表.bat”文件,万一项目无法启动后点击“鲜迪狐表.bat”文件让项目恢复启动,现在卡壳在解压缩文件的语句里。
用ZipFile命令已经试过,发现真发生项目无法启动时这命令不顶用(当然本人水平有限是主要原因)