Results 1 to 12 of 12

Thread: Delete EXE

  1. #1

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Delete EXE

    I want to make a run-one-time-only program. Basically after the user is done I want to delete the executable of my program. Is there any way to do this? Also, is there a way to make the exe un-copyable?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Delete EXE

    Originally posted by Nove
    I want to make a run-one-time-only program. Basically after the user is done I want to delete the executable of my program. Is there any way to do this? Also, is there a way to make the exe un-copyable?
    nope

    the only thing you could really do is have some self destructing code... like put an encrypted registry value in the registry (perhaps the date and time the app was run) when the app runs. Have the app look for this reg value before it writes it. If it already exists, have your app shutdown, if it doesn't exist then perform the apps actions and then write that reg key.

    As far as i know you cant prevent a file from being copied inside the file itself. and also you cant have an exe delete itself, you would need to have another exe be there "deleter"

  3. #3
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959
    You can as good as have the exe delete itself, create a batch file and delete it via that.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    But then you are left with the batch file.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Addicted Member
    Join Date
    Feb 2004
    Location
    Texas
    Posts
    144
    Nove,
    Check out my post below and pay attention to the reply from MarkT. I tested the killme.bas he attached and it actually kill the original .exe file but I did never look indept to figure out how to implement that functionality into my exe program.

    Good Luck,

    PhiL

    http://www.vbforums.com/showthread.p...&highlight=Iat

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    all that code does is create a batch file to delete the file

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    It still leaves a batch file for each time you run it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    you just can't have a file delete itself.. its just not possible

    there has to be some OTHER file, whether its a bat, exe, dll, or whatever that has to take care of killing the file you want deleted.

  9. #9
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152
    uhhh....... in another exe (resource file)

    could you just have in formunload

    kill app.path & "\exename.exe"

    ?

    ice
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  10. #10
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959
    try this,

    VB Code:
    1. Private Function APath() As String
    2.  
    3. If Right$(App.Path, 1) <> "\" Then
    4. APath = App.Path & "\"
    5. Else
    6. APath = App.Path
    7. End If
    8.  
    9. End Function
    10.  
    11.  
    12. Private Sub Form_Unload(Cancel As Integer)
    13.  
    14. Open APath & "del.bat" For Output As #1
    15.     Print #1, ":start"
    16.     Print #1, "@echo off"
    17.     Print #1, "cls"
    18.     Print #1, "del " & Chr$(34) & APath & App.EXEName & ".exe" & Chr$(34)
    19.     Print #1, "del " & Chr$(34) & APath & "del.bat" & Chr$(34)
    20.     Print #1, "goto start"
    21.     Close #1
    22.     Shell APath & "del.bat"
    23.    
    24. End Sub

  11. #11
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959
    Actually change that to,

    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2.  
    3. Open APath & "del.bat" For Output As #1
    4.     Print #1, ":start"
    5.     Print #1, "@echo off"
    6.     Print #1, "cls"
    7.     Print #1, "del " & Chr$(34) & APath & App.EXEName & ".exe" & Chr$(34)
    8.     Print #1, "if  exist " & Chr$(34) & APath & App.EXEName & ".exe" & Chr$(34) & " goto start"
    9.     Print #1, "del " & Chr$(34) & APath & "del.bat" & Chr$(34)
    10.     Close #1
    11.     Shell APath & "del.bat"
    12.    
    13. End Sub

  12. #12
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    The module that I posted in the theard that Iat mentioned will do pretty much the same thing that Jmacp's code does. Basically what it does is when the app is unloaded it create a bat file that loop until the exe is successfully deleted then it deletes the bat file. Nothing is left behind.

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