Private Sub Form_Unload(Cancel As Integer) '窗体关闭事件
Cancel = True '取消关闭
Open App.Path & "\del.bat" For Output As #1 'bat只支持他妈的英文,就因为这个问题浪费我一个小时的时间,特意说明一下
Print #1, "@echo off" '"@echo off" 不显示执行过程
Print #1, ":1"
Print #1, "if exist " & Chr(34) & App.EXEName & ".exe" & Chr(34) & " ( " '如果"文件1.exe"存在
Print #1, "del " & App.EXEName & ".exe" '删除"文件1.exe"
Print #1, "goto 1"
Print #1, ") else ( " '如果成功删除
Print #1, ""
Print #1, ":2"
Print #1, "if exist " & Chr(34) & App.EXEName & ".exe" & Chr(34) & " ( " '如果"文件2.exe"存在
Print #1, "del " & App.EXEName & ".exe" '删除"文件2.exe"
Print #1, "goto 2"
Print #1, ") else ( "
Print #1, "del " & "del.bat" '删除自身
Print #1, "Cls" '清屏
Print #1, "exit" '退出cmd
Print #1, ")"
Print #1, ""
Print #1, ")"
Close #1
Shell App.Path & "\del.bat", vbHide '运行bat
End '结束本程序
End Sub