Results 1 to 21 of 21

Thread: [RESOLVED] Delete Yourself? = possible ??

  1. #1

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Resolved [RESOLVED] Delete Yourself? = possible ??

    Hello,

    Im doing a custom Uninstaller, however is there a way to Delete yourself after you're done..?

    It wont allow me to.. is there any other way..? maybe through API's?

    ..Or i just though of doing another .exe to be extracted to the Temp folder to kill the Uninstall file at the end.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Delete Yourself? = possible ??

    Yes, there is a non-API way, i.e. using Batch file.

    Check this link.
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Delete Yourself? = possible ??

    Ok.. Nice 1 there...


    VB Code:
    1. Dim path As String
    2. path = App.path & "\"
    3.  
    4. Open path & "clearup.bat" For Output As #1
    5.     Print #1, ":start"
    6.     Print #1, "@echo off"
    7.     Print #1, "cls"
    8.     Print #1, "del " & Chr$(34) & path & App.EXEName & ".exe" & Chr$(34)
    9.     Print #1, "if  exist " & Chr$(34) & path & App.EXEName & ".exe" & Chr$(34) & " goto start"
    10.     Print #1, "del " & Chr$(34) & path & "clearup.bat" & Chr$(34)
    11.     Close #1
    12.     Shell path & "clearup.bat"

    That works nice for me.. but how bout removing the whole Folder from Program Files...?

    the rmdir path doesnt seem to be working for me
    I tried it via the normal command prompt, and it wouldnt delete the folder.

    Does anyone know the proper syntax?
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  4. #4
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Delete Yourself? = possible ??

    RmDir works only if complete folder is empty (there's absolutely nothing in there). Type HELP in Command Prompt to see all batch instructions...

  5. #5
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: Delete Yourself? = possible ??

    Have you tried the Kill() function, that might work I cant remember though
    Chris

  6. #6

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Delete Yourself? = possible ??

    RmDir works only if complete folder is empty (there's absolutely nothing in there)
    To test i did an Empty folder which contains 2 other folders in it...

    VB Code:
    1. FolderMain
    2.     :--->Folder1
    3.        :----->Folder2

    Im trying to delete Folder 2 which has nothing in it.. but it wont work..
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  7. #7
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Delete Yourself? = possible ??

    Depends "where" you are, but it should work. If you have "c:\test" and sub-folders "1" and "2", you can delete one of theme from "c:\test" like this:
    Code:
    RmDir 1
    But if you're on a root ("c:\") you should call it like this:
    Code:
    RmDir \test\2
    ... to delete what's left. Then you can simply temove "test" from the root.

  8. #8
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Delete Yourself? = possible ??

    Quote Originally Posted by some1uk03
    To test i did an Empty folder which contains 2 other folders in it...

    VB Code:
    1. FolderMain
    2.     :--->Folder1
    3.        :----->Folder2

    Im trying to delete Folder 2 which has nothing in it.. but it wont work..
    you have to work inside out

    rmdir folder2
    rmdir folder1
    rmdir foldermain

    but you will need to include the full path to that folder because the app might not find it.

  9. #9
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Delete Yourself? = possible ??

    "Deltree" is a command used to delete files and directories. but it is not available with Windows 2000, windows XP and above
    CS

  10. #10
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Delete Yourself? = possible ??

    You can use

    RmDir /s

    option to remove all directories and files in the specified directory in addition to the directory itself. Used to remove a directory tree.
    VB Code:
    1. Public Sub RemoveDirectory(ByVal sDir As String)
    2.     Shell "Cmd.exe /C Rmdir /S /Q " & sDir
    3. End Sub
    4. 'How can I call this function
    5. 'Call RemoveDirectory("C:\Temp\Test\")
    This will delete all files and folders under C:\Temp\Test\ folder.
    Last edited by cssriraman; Nov 26th, 2006 at 12:27 PM.
    CS

  11. #11

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Delete Yourself? = possible ??

    How do you call a batch withing a batch..?

    I did...

    Print #1, "cd " & Chr$(34) & path & Chr$(34)

    but dont seem to be calling it...
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  12. #12
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Delete Yourself? = possible ??

    you mean batch file.

    Call <batch file name>

    For example,

    Call rmd.bat

    The batch file should be present on the same directory.
    CS

  13. #13
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Delete Yourself? = possible ??

    Why on earth would you need to do any of this for an UNINSTALL???? That is what the installers already do...

  14. #14

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Delete Yourself? = possible ??

    Randem:

    Because the Inno uninstaller doesnt support Code, thus i created my own .exe in Vb to do the Uninstalling for me.. which it does fine ..

    My only problem is.. to delete the app folder from Program Files..

    So far i get it to clear everything inside "C:\Program Files\MyApp\" including the uninstall.exe

    Basically the batch file deletes the uninstall.exe which then should call another batch file inside the Program Files so it could delete MyApp from there and thats it...
    But the second batch doesnt get called..>!!
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  15. #15
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Delete Yourself? = possible ??

    Quote Originally Posted by some1uk03
    Because the Inno uninstaller doesnt support Code...
    What Code are you talking about??

  16. #16

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Delete Yourself? = possible ??

    What Code are you talking about??
    Its a simple thing.. but in another post of mine i found out that the Inno Setup doesnt use the Code section for Uninstall.

    check it out here: Post1 (Read Kleinma's post) & Post 2

    Its basically.. it should check n see if a folder exists... prompt the user if they would like to keep or delete it....
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  17. #17
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Delete Yourself? = possible ??

    http://support.microsoft.com/kb/140570. See "APPLIES TO" near the bottom of the page for possible limitations.

  18. #18
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Delete Yourself? = possible ??

    What you really want to do is set the indicators in the Win.ini file so that those files and folders will be deleted upon the next restart.

  19. #19

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Delete Yourself? = possible ??

    VB Code:
    1. // Move szSrcFile to szDstFile next time system is rebooted
    2.    MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);

    Ok i added that to the End of the Win.Ini file..

    However i dont understand weather it needs to be under the [Rename] section or just at the end of the file.

    The [Rename] section i beliave is only for Win95 and its not really clear where to put the MoveFileEx code for WinNT, so i assume just the end of the file...
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  20. #20
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: Delete Yourself? = possible ??

    Quote Originally Posted by some1uk03
    VB Code:
    1. // Move szSrcFile to szDstFile next time system is rebooted
    2.    MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);

    Ok i added that to the End of the Win.Ini file..

    However i dont understand weather it needs to be under the [Rename] section or just at the end of the file.

    The [Rename] section i beliave is only for Win95 and its not really clear where to put the MoveFileEx code for WinNT, so i assume just the end of the file...
    No, no, no, no, no, no, no, no, NO! Let's say you have a folder "C:\MyApp", contains "Project1.exe", "test.txt", "UDT.txt" and a subfolder "SubFolder" - which contains "test.reg". To delete the lot at reboot:
    VB Code:
    1. Option Explicit
    2.  
    3. 'THIS FILE is "Project1.exe"
    4.  
    5. Private Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" _
    6.    (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Long) As Long
    7.  
    8. Private Const MOVEFILE_DELAY_UNTIL_REBOOT = &H4
    9.  
    10. Private Sub Form_Click()
    11.    Call MoveFileEx("C:\MyApp\Project1.exe", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
    12.    Call MoveFileEx("C:\MyApp\test.txt", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
    13.    Call MoveFileEx("C:\MyApp\UDT.txt", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
    14.    Call MoveFileEx("C:\MyApp\SubFolder\test.reg", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
    15.    Call MoveFileEx("C:\MyApp\SubFolder", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
    16.    Call MoveFileEx("C:\MyApp", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
    17. End Sub

  21. #21

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Delete Yourself? = possible ??

    Aaaaaha.. Nice 1 schoolbusdriver

    It works...

    Although would be nice to do it without a restart.. : ) but anyway.. who cares.. LOL
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



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