VB 代码删除程序自身

VB 代码删除程序自身

在程序中要调用退出删除可用:
Call Form_QueryUnload(1,2)

'注意:这个代码不要在VB的IDE环境中执行.否则将删除VB6.EXE
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Open "a.bat" For Append As #1
Print #1, "@ECHO OFF"
Print #1, ":START"
Print #1, "IF NOT EXIST """ & App.EXEName & ".exe"" GOTO FILENOTFOUND"
Print #1, "DEL """ & App.EXEName & ".exe"""
Print #1, "GOTO START"
'文章来自Net0and1.com,Net零和壹
Print #1, ":FILENOTFOUND"
Print #1, "DEL A.BAT"
Print #1, "CLS"
Print #1, "EXIT"
Close #1
Shell "a.bat", vbHide
End
End Sub
posted @ 2009-06-11 11:05  随便取个名字算了  阅读(444)  评论(0编辑  收藏  举报