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

你可能感兴趣的:(vb)