[bb] Self-Destructing .exe by Subirenihil [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:42

Previous topic - Next topic

BlitzBot

Title : Self-Destructing .exe
Author : Subirenihil
Posted : 1+ years ago

Description : Be sure to add the proper lines to shell32.decls

Compile into an empty folder, then run the compiled version to see it self-destruct.

Not sure what would happen if you try to run by just hitting "F5" in the editor - could be very bad (as in deleting part of blitz).


Code :
Code (blitzbasic) Select
;Compile in its own folder as "Self-Destruct.exe"
;Run the compiled version and it will delete itself
;
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;!! DO NOT RUN FROM WITHIN BLITZ !!
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

;The following lines must be in shell32.decls
;   .lib "shell32.dll"
;   ShellExecute%(hwnd%,Operation$,File$,Parameters$,Directory$,ShowCmd%):"ShellExecuteA"

Graphics 400,300,0,2
SetBuffer FrontBuffer()

SelfDestruct
Text 200,150,"Press any key to self destruct...",1,1
WaitKey
End

Function SelfDestruct()
dir$=SystemProperty("appdir")
If Right$(dir$,1)<>"" Then dir$=dir$+""

tempdir$=SystemProperty("tempdir")
If Right$(tempdir$,1)<>"" Then tempdir$=tempdir$+""

file$=dir$+"Self-Destruct.exe"
temp$=tempdir$+"_uninstSelf-Destruct.bat"

bat=WriteFile(temp$)

WriteLine bat,":Repeat"
WriteLine bat,"del "+Chr$(34)+file$+Chr$(34)
WriteLine bat,"if exist "+Chr$(34)+file$+Chr$(34)+" goto Repeat"
WriteLine bat,"rmdir "+Chr$(34)+Left$(dir$,Len(dir$)-1)+Chr$(34)
WriteLine bat,"del "+Chr$(34)+temp$+Chr$(34)

CloseFile bat
ShellExecute 0,"open",Chr$(34)+temp$+Chr$(34),"","",0
End Function


Comments :


H&K(Posted 1+ years ago)

 Well done.


Yo! Wazzup?(Posted 1+ years ago)

 I agree with H&K - A job well done :)


*(Posted 1+ years ago)

 this could be good for program updates too, you could download them, create the batch file to overwrite the original the close the exe and restart the file.