Results 1 to 25 of 25

Thread: [RESOLVED] Get a program to delete its self and close

  1. #1

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    Resolved [RESOLVED] Get a program to delete its self and close

    Ok how do i get my program to delete its self? Because when i do Kill or My.Computer.FileSystem.DeleteFile the Access is denied because its still running. So how do i get it to delete its self

  2. #2
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: Get a program to delete its self and close

    i could think of a way, but it just seems odd that previously you wanted to disconnect a remote computer, and now you want a program to delete itself... i dunno.. im still seeing red flags.

    what are you trying to accomplish as an end goal here?

  3. #3
    Member sh4de's Avatar
    Join Date
    Aug 2009
    Location
    Irvine, CA
    Posts
    48

    Re: Get a program to delete its self and close

    In the spirit of you breaking something so we all get paid to fix it... Write out a .bat file which deletes the executable path directory and set that batch file to run on system boot, then shutdown the computer

    Same thing..and fun
    Senior Developer @
    Integrated Systems Solutions

  4. #4
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: Get a program to delete its self and close

    It does seem odd, but just as an academic exercise I would suggest the use of a batch file triggered in the application_exit event which would wait for approximately 5 seconds before deleting the program file.

  5. #5
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: Get a program to delete its self and close

    actually i have done this before in vb6 - same will apply for .net tho ... create the bat file that looks kinda like the following from with in your project:

    Code:
    :StartOver
    del myApp.exe
    IF EXIST myApp.exe GOTO StartOver
    del thisbat.bat
    Then run the bat from your interface:
    Code:
     Shell("delme.bat", AppWinStyle.Hide)
    then close your app

  6. #6
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Re: Get a program to delete its self and close

    You should use this code in .NET
    vb.net Code:
    1. Process.Start("delete_me")
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  7. #7
    Hyperactive Member storm5510's Avatar
    Join Date
    Jul 2009
    Location
    Indiana, U.S.A.
    Posts
    329

    Re: Get a program to delete its self and close

    Is there a specific reason for wanting to do this?

    I can only think of one: A destructive application that deletes files, folders, or worse, then removes itself to hide its tracks.

  8. #8

  9. #9
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Re: Get a program to delete its self and close

    It doesn't make much sense why an uninstaller would delete itself after it does it job. I'm seeing red flags...

    @Seraph: Ahahahaha, yeah, lol. Now that I think it true, DUH! Lol. Anyhow, what I was trying to imply is that it sounds kind of weird.
    Last edited by tassa; Aug 7th, 2009 at 08:59 AM.
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  10. #10
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Get a program to delete its self and close

    tassa: errr...Uninstallers always delete themselves. lol

    Well, in theory this program wants to log someone off a computer remotely.
    Emcrank already said he owns the connection.
    He will need credentials of the target PC to be able to do this.
    And, how malicious can it be when after it deletes itself, you can get right back on.

    The whole things sounds fishy to me too, but not sure what all that will accomplish.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  11. #11
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Get a program to delete its self and close

    really? I've never had an installer delete itself... the app sure... but the install file is always still there.... good thing too... sometimes I uninstall an app so I can reinstall it... the msi file doesn't disappear when I finish.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Get a program to delete its self and close

    If you have a program that doesn't have the installer and uninstaller in the same executable it does. Like with INNO installer, the installer installs the program, and during installation it creates an uninstaller with specific instructions for deleting anything you flagged in INNO to uninstall (e.g. Registry keys that were created during the istallation, etc. And, in the end, the uninstaller is deleted as well since it is just that, an uninstaller; nothing else.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  13. #13
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: Get a program to delete its self and close

    seems like he would've said "I am trying to uninstall my program and I would like the uninstaller to be deleted as well. How can I accomplish this?"

    getting a program to close itself and delete sounds a bit different to me

  14. #14
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Get a program to delete its self and close

    Except that he called it an uninstaller after the fact. lol.
    I know, it still seems shady, but we don't know much about it.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  15. #15
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: Get a program to delete its self and close

    so we should wait for him to provide some detailed information before throwing all these ideas at him.

  16. #16
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Get a program to delete its self and close

    Then let's ask more straightforward. lol

    Emcrank, what exactly is your program supposed to accomplish?
    It seems no one here is willing to help because what you have described, thus far, seems a tad bit shady. (And I don't blame anyone for that; I'm thinking it's fishy too.)

    And your reluctance to be forthcoming with the purpose of your program isn't helping either. Normally, when people have asked questions and sounded shady, they were willing to speak up and explain their true intent when confronted.

    It seems you might get a better reception and more help in this issue if you were to just make everyone happy and let us know what exactly this whole program is supposed to do.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  17. #17

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    Re: Get a program to delete its self and close

    I Completly scrapped the thing about the disconnecting the internet it was to hard for me.
    Anyway all i want is an uninstaller to uninstall my program and then uninstall its self so there is nothing left about it. Okay?

  18. #18
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Get a program to delete its self and close

    INNO Setup.
    You can create an installer for your program, and it automatically creates an uninstaller for it.

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  19. #19

  20. #20
    Hyperactive Member storm5510's Avatar
    Join Date
    Jul 2009
    Location
    Indiana, U.S.A.
    Posts
    329

    Unhappy Re: Get a program to delete its self and close

    Various Downloads Very Handy For Renegade Users

    This is from his web site. You all do what you want. I'm done here.


  21. #21

  22. #22
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Get a program to delete its self and close

    Quote Originally Posted by storm5510 View Post
    Various Downloads Very Handy For Renegade Users

    This is from his web site. You all do what you want. I'm done here.

    oops lol

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  23. #23

  24. #24
    Fanatic Member Seraph's Avatar
    Join Date
    Jul 2007
    Posts
    959

    Re: Get a program to delete its self and close

    He was thinking you meant hacking and stateofidleness was making it clear renegade referred to Command and Conquer. lol

    Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7

    SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
    [Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]

    [.NET and MySQL Quick Guide]

  25. #25

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