Results 1 to 20 of 20

Thread: Self-Dustruction

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Montreal
    Posts
    17
    Hello
    is there a way to make a progra delete it self, copying a command to the memory and runing form the mem after the prog has ended, be cause i also thought of puting stuff in the registery but i don't what that, how could i make a program delete it self, like Kill App.path & "\Filename.exe"
    with-out othere help form othere app's

  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    well you can't actually kill your program from with in your program. But there are several things you can do to make it happen. First maybe send information to the task sched. that comes with windows. Or like you mentioned, send info to the registry and make it del your program on a specific date or whatever. But as for killing from with in i don't think that's possible. You COULD however del files that are needed by your appl to run...like some dlls and ocx are needed but are not used through out the whole run time, so have them deleted and the next time the user tries to use a certain function it will give him an error and close the program...


    gl,
    D!m
    Dim

  3. #3
    Guest
    I had to do this once and I came up with a pretty kewl way of doing it.. Along with your application make another application no gui or anything just One line of code that will kill whatever yur application is!

    To keep users from running it out of curiousity I used the Shell function in the small program to retrieve a password I used when I called the program from the big one. like

    c:\whatever\deleter.exe -KillerPassword

    The small program will check the path if the password is right it will delete your application. If your application is running use some simple API to close it down.

    wallah..Not to fancy but it works nicely =]

  4. #4
    Guest
    Hmm...whenever I do something like Kill "C:\myapps\app\appname.exe", I get an error. Or any file that is in use. Even Deltree.exe won't delete something that is in use.

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    magadass, how did you managed to delete the deleter.exe then? Just curious because you're with the same problem then
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219
    ok here what you do you open autoexec.bat and tell it to delete your program say like

    Code:
    open "C:\Autoexec.bat" For Append As #1
    print #1,"Deltree " & App.Path & "\" & App.ExeName & ".Exe"
    close #1
    so now next time they load up the computer the file well be gone
    me

  7. #7
    Guest
    Actually, there is another way. Through bat file..as what you did, but not using autoexec. But you have to have the file closed :P.
    Code:
    Open App.path & "\tempdel.bat" For Output As #1
    'Print #1, "@ECHO OFF" 'Turn this on if you want the user to see what your doing
    Print #1, "IF EXIST " & """" & App.Path & "\project1.exe" & """" & " DEL " & """" & App.Path & "\project1.exe" & """"
    Print #1, "Del """ & App.Path & "\tempdel.bat"""
    Close #1
    This is cool though .

    [Edited by Matthew Gates on 07-15-2000 at 07:03 PM]

  8. #8
    Guest
    Your left with nothing..The program will only execute if it finds the password in the shell so you have a 3kb file just chillin there.


  9. #9
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219
    and after my code i should you you should restart the computer and im not writing the hole program for you
    me

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Montreal
    Posts
    17

    Found -it

    Hey i have found the answer it's easy
    i made small Qbasic dos prog that would kill it self
    so that's it
    Shell "Selfkill.exe" & app.path & "Filename.exe",Vbhide
    END
    Voila !!
    that's it !

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Matthew, the """"""'s

    Hehe, just noticed your """"""""""'s and could explain;

    "" inside the " "quotes means one ", so you don't have to put four" to add a" in your text.

    For instace:
    Code:
    "text""text"
    "text"""
    """text"
    """"
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    New Member Martin's Avatar
    Join Date
    Apr 1999
    Location
    Alleroed, Denmark
    Posts
    10

    Lightbulb The forgotten API of death

    Hey guys

    I once read about an API that would free the file somehow, so it can be deleted though still running. I don't remember the name, though. I'll post later if I find out about it.
    Martin

  13. #13
    Guest

    Re: Matthew, the

    Originally posted by kedaman
    Hehe, just noticed your """"""""""'s and could explain;

    "" inside the " "quotes means one ", so you don't have to put four" to add a" in your text.

    For instace:
    Code:
    "text""text"
    "text"""
    """text"
    """"
    Heh kedaman, I don't feel comfortable with messing around with the Kill or Del command to much.
    It makes me nervous.
    One command Kill "C:\" or Del C:\ can screw up your whole career ;].
    That is why I did all those quotes, either way, it still works.

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Montreal
    Posts
    17
    Kill or del
    will only delete the file's that are not hidden or direcotory's

  15. #15
    New Member
    Join Date
    Feb 2000
    Location
    Salem, Oregon, USA
    Posts
    14

    Lightbulb Figured it out!

    Hey everyone, I figured it out! By CREATING a batch file within your app, running it, and then actually killing your own process, the timing should be just right to delete itself... Here is the code that WORKS!

    Code:
    Option Explicit
    Public Declare Function _
      GetWindowThreadProcessId Lib "user32" _
      (ByVal hwnd As Long, _
      lpdwProcessId As Long) As Long
    
    Public Declare Function _
      GetLastError Lib "kernel32" () As Long
    
    Public Declare Function _
      OpenProcess Lib "kernel32" _
      (ByVal dwDesiredAccess As Long, _
      ByVal bInheritHandle As Long, _
      ByVal dwProcessId As Long) As Long
    
    Public Declare Function _
      TerminateProcess Lib "kernel32" _
      (ByVal hProcess As Long, _
      ByVal uExitCode As Long) As Long
    
    Public Const PROCESS_TERMINATE = &H1
    
    Public Function KillApp(WindowHandle As Long)
      Dim lngTest As Long
      Dim ProcessID As Long
      lngTest = GetWindowThreadProcessId(WindowHandle, ProcessID)
      If lngTest = 0 Then
        lngTest = GetLastError
        MsgBox "Failed with error code: " & lngTest, _
          vbOKOnly + vbCritical, "Error"
        Exit Function
      End If
      lngTest = OpenProcess(PROCESS_TERMINATE, 1, ProcessID)
      If lngTest = 0 Then
        lngTest = GetLastError
        MsgBox "Failed with error code: " & lngTest, _
          vbOKOnly + vbCritical, "Error"
        Exit Function
      End If
      
      Open App.Path & "\" & App.EXEName & ".bat" _
        For Output As #1
      Print #1, "del " & Chr(34) & App.Path & "\" & _
        App.EXEName & ".exe" & Chr(34)
      Print #1, "del " & Chr(34) & App.Path & "\" & _
        App.EXEName & ".bat" & Chr(34)
      Close
      Shell App.Path & "\" & App.EXEName & ".bat", vbHide
      lngTest = TerminateProcess(lngTest, 0)
      If lngTest = 0 Then
        lngTest = GetLastError
        MsgBox "Failed with error code: " & lngTest, _
          vbOKOnly + vbCritical, "Error"
        Exit Function
      End If
    End Function
    [Edited by Litehouse on 07-27-2000 at 07:45 PM]

  16. #16
    New Member
    Join Date
    Feb 2000
    Location
    Salem, Oregon, USA
    Posts
    14
    And if I wanted to have to restart the machine, then maybe I would use a route such as that... But who wants to have to restart the machine, just to delete a file? That's a bit ridiculous! Thanks for the tip about that ini though... I'd never tried it... I worked quite a bit with the API on this one, including UnlockFile etc., and my previous code post seemed to be the most reliable solution, ie, worked every time.

    L8r ppl...
    Litehouse

  17. #17
    Junior Member
    Join Date
    Jul 1999
    Location
    Scarbrough, Maine, USA
    Posts
    17

    Lightbulb This werks Instantly

    Open App.Path & "\" & App.EXEName & ".bat" For Append As #1
    Print #1, "del " & App.Path & "\" & App.EXEName & ".exe"
    Print #1, "del " & App.Path & "\" & App.EXEName & ".bat"
    Close #1

    Dim I
    For I = 0 To 100
    DoEvents
    Next I
    Dim X
    X = Shell(App.Path & "\" & App.EXEName & ".bat")
    End
    Visual Basic 6.0 enterprise
    windows 2000 pro
    intell PentiumII 233mhz
    128megs ram

  18. #18
    Guest
    Wow!

    This is an old as hell thread!

  19. #19
    Junior Member
    Join Date
    Jul 1999
    Location
    Scarbrough, Maine, USA
    Posts
    17

    Red face Sorry I was bored

    Had nothing else to do, sorry!
    Visual Basic 6.0 enterprise
    windows 2000 pro
    intell PentiumII 233mhz
    128megs ram

  20. #20
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    hehe, i thought this only happens to me matt
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width