在vb程序中
能否运行程序结束后,
自动删除自己。
Private Sub DeleteMe()
-----------Create bat-file---------------
Open App.Path + "\Delself.bat" For Append As #1
Print #1, "@echo off"
Print #1, ":try"
Print #1, "del " + App.EXEName + ".exe"
Print #1, "if exist " + App.EXEName + ".exe goto try"
Print #1, "del " + App.Path + "\Delself.bat"
Close
-----------Executr it-------------------
Shell App.Path + "\Delself.bat", vbHide
End Sub
At Form_Unload (or at the end of Sub_Main)
just call:DeleteMe
一个自杀程序
--------------------------------------------------------------------------------
下面的代码演示将一个程序在执行时将自己删除。
Sub KillMe()
Path = App.Path
If Right(Path, 1) <> "\" Then Path = Path + "\"
PathName = Path + App.EXEName + ".EXE"
BatName = Path + "1.bat"
Open BatName For Output As #1
Print #1, ":START"
Print #1, "del " & PathName
Print #1, "if exist " & BatName & " GOTO START"
Print #1, "del " & BatName
Close #1
Shell BatName, vbHide
End
End Sub
注: Print #1, "if exist " & BatName & " GOTO START"
这一句有的机加了不能把那个.bat删了,有的可以自己看看!