I have created an installer using Inno Setup which contains 5 files in it. I have added an additional feature so that user can install it in custom path.
After installing, a folder will be created in selected path. Now I will copy some other files in this folder. But after un-installation the following cases are happening:
let user installs it in default location, then a new folder say myfolder is created in that location, now user creates 2 new files and copies them in this folder. After un-installing there is no problem; myfolder will be deleted along with 2 new files(which are created after installing).
now let user install it in custom location, then a new folder say myfolder is created in that location, now user creates 2 new files and copies them in this folder. after uninstalling myfolder is not deleting since 2 new files in it (which are created after installing).
Here is my code:
function GetInstalledLocation(): String;
var
installLocation: String;
begin
if RegKeyExists(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ {36CBFC-6ACC-4232-90CF-E95BC473C168}_is1') then
begin
RegQueryStringValue(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1536CBFC-6ACC-4232-90CF-E95BC473C168}_is1', 'InstallLocation', installLocation);
Result := installLocation
end;
end;
function InitializeUninstall(): Boolean;
var
InstalledLocation : String;
begin
Result := PromptUntilProgramClosedOrInstallationCanceled( ProgramRunningOnUninstallMessage, True );
// Unload the DLL, otherwise the dll psvince is not deleted
UnloadDLL(ExpandConstant('{app}\psvince.dll'));
if not Result then
begin
MsgBox( UninstallationCanceledMessage, mbInformation, MB_OK );
end
else
begin
InstalledLocation := GetInstalledLocation();
;DelTree('{InstalledLocation\*}', True, True, True);
DelTree('{InstalledLocation}', True, True, True);
; DelTree('ExpandConstant({InstalledLocation\*})', True, True, True);
end;
end;
[UninstallDelete]
;This works only if it is installed in default location
Type: filesandordirs; Name: "{pf}\{#MyAppName}"
But I want to delete the folder along with the new files i.e. I want to delete nonempty folder in inno setup . How can I do it ?
ya now its working , i used following code :
[UninstallDelete]
;This works only if it is installed in default location
Type: filesandordirs; Name: "{pf}\{#MyAppName}"
;This works if it is installed in custom location
Type: files; Name: "{app}\*";
Type: filesandordirs; Name: "{app}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With