|
-
Nov 26th, 2006, 05:54 AM
#1
Thread Starter
Frenzied Member
[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.

-
Nov 26th, 2006, 06:17 AM
#2
Re: Delete Yourself? = possible ??
Yes, there is a non-API way, i.e. using Batch file.
Check this link.
-
Nov 26th, 2006, 08:29 AM
#3
Thread Starter
Frenzied Member
Re: Delete Yourself? = possible ??
Ok.. Nice 1 there...
VB Code:
Dim path As String
path = App.path & "\"
Open path & "clearup.bat" For Output As #1
Print #1, ":start"
Print #1, "@echo off"
Print #1, "cls"
Print #1, "del " & Chr$(34) & path & App.EXEName & ".exe" & Chr$(34)
Print #1, "if exist " & Chr$(34) & path & App.EXEName & ".exe" & Chr$(34) & " goto start"
Print #1, "del " & Chr$(34) & path & "clearup.bat" & Chr$(34)
Close #1
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.

-
Nov 26th, 2006, 09:28 AM
#4
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...
-
Nov 26th, 2006, 10:07 AM
#5
Re: Delete Yourself? = possible ??
Have you tried the Kill() function, that might work I cant remember though
-
Nov 26th, 2006, 10:31 AM
#6
Thread Starter
Frenzied Member
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:
FolderMain
:--->Folder1
:----->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.

-
Nov 26th, 2006, 10:43 AM
#7
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:But if you're on a root ("c:\") you should call it like this:... to delete what's left. Then you can simply temove "test" from the root.
-
Nov 26th, 2006, 11:56 AM
#8
PowerPoster
Re: Delete Yourself? = possible ??
 Originally Posted by some1uk03
To test i did an Empty folder which contains 2 other folders in it...
VB Code:
FolderMain
:--->Folder1
:----->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.
-
Nov 26th, 2006, 12:01 PM
#9
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
-
Nov 26th, 2006, 12:03 PM
#10
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:
Public Sub RemoveDirectory(ByVal sDir As String)
Shell "Cmd.exe /C Rmdir /S /Q " & sDir
End Sub
'How can I call this function
'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
-
Nov 26th, 2006, 12:34 PM
#11
Thread Starter
Frenzied Member
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.

-
Nov 26th, 2006, 12:41 PM
#12
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.
-
Nov 26th, 2006, 12:53 PM
#13
-
Nov 26th, 2006, 01:10 PM
#14
Thread Starter
Frenzied Member
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.

-
Nov 26th, 2006, 01:36 PM
#15
Re: Delete Yourself? = possible ??
 Originally Posted by some1uk03
Because the Inno uninstaller doesnt support Code...
What Code are you talking about??
-
Nov 26th, 2006, 01:46 PM
#16
Thread Starter
Frenzied Member
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.

-
Nov 26th, 2006, 05:05 PM
#17
Re: Delete Yourself? = possible ??
http://support.microsoft.com/kb/140570. See "APPLIES TO" near the bottom of the page for possible limitations.
-
Nov 27th, 2006, 12:38 AM
#18
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.
-
Nov 27th, 2006, 05:32 AM
#19
Thread Starter
Frenzied Member
Re: Delete Yourself? = possible ??
VB Code:
// Move szSrcFile to szDstFile next time system is rebooted
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.

-
Nov 27th, 2006, 08:52 AM
#20
Re: Delete Yourself? = possible ??
 Originally Posted by some1uk03
VB Code:
// Move szSrcFile to szDstFile next time system is rebooted
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:
Option Explicit
'THIS FILE is "Project1.exe"
Private Declare Function MoveFileEx Lib "kernel32" Alias "MoveFileExA" _
(ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal dwFlags As Long) As Long
Private Const MOVEFILE_DELAY_UNTIL_REBOOT = &H4
Private Sub Form_Click()
Call MoveFileEx("C:\MyApp\Project1.exe", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
Call MoveFileEx("C:\MyApp\test.txt", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
Call MoveFileEx("C:\MyApp\UDT.txt", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
Call MoveFileEx("C:\MyApp\SubFolder\test.reg", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
Call MoveFileEx("C:\MyApp\SubFolder", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
Call MoveFileEx("C:\MyApp", vbNullString, MOVEFILE_DELAY_UNTIL_REBOOT)
End Sub
-
Nov 27th, 2006, 10:12 AM
#21
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|