December 04, 2020, 11:13:53 AM

Author Topic: [bb] Self-Destructing .exe by Subirenihil [ 1+ years ago ]  (Read 573 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Self-Destructing .exe by Subirenihil [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
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
  1. ;Compile in its own folder as "Self-Destruct.exe"
  2. ;Run the compiled version and it will delete itself
  3. ;
  4. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  5. ;!! DO NOT RUN FROM WITHIN BLITZ !!
  6. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  7.  
  8. ;The following lines must be in shell32.decls
  9. ;   .lib "shell32.dll"
  10. ;   ShellExecute%(hwnd%,Operation$,File$,Parameters$,Directory$,ShowCmd%):"ShellExecuteA"
  11.  
  12. Graphics 400,300,0,2
  13. SetBuffer FrontBuffer()
  14.  
  15. SelfDestruct
  16. Text 200,150,"Press any key to self destruct...",1,1
  17. WaitKey
  18. End
  19.  
  20. Function SelfDestruct()
  21.         dir$=SystemProperty("appdir")
  22.         If Right$(dir$,1)<>"" Then dir$=dir$+""
  23.  
  24.         tempdir$=SystemProperty("tempdir")
  25.         If Right$(tempdir$,1)<>"" Then tempdir$=tempdir$+""
  26.        
  27.         file$=dir$+"Self-Destruct.exe"
  28.         temp$=tempdir$+"_uninstSelf-Destruct.bat"
  29.        
  30.         bat=WriteFile(temp$)
  31.        
  32.         WriteLine bat,":Repeat"
  33.         WriteLine bat,"del "+Chr$(34)+file$+Chr$(34)
  34.         WriteLine bat,"if exist "+Chr$(34)+file$+Chr$(34)+" goto Repeat"
  35.         WriteLine bat,"rmdir "+Chr$(34)+Left$(dir$,Len(dir$)-1)+Chr$(34)
  36.         WriteLine bat,"del "+Chr$(34)+temp$+Chr$(34)
  37.        
  38.         CloseFile bat
  39.         ShellExecute 0,"open",Chr$(34)+temp$+Chr$(34),"","",0
  40. 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.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal