
shust87 asked a question.
Remove folder in AppDataFolder during Uninstall
I have Basic MSI project. This is installation package for Windows Forms application.
User installs it, starts working and can store some user settings (for example, form's size, location,...) to xml files located at c:\Users\username\AppData\Roaming\MyProjectNameFolder
I'm trying to implement possibility of removing these setting files during uninstall. For this purpose I added simple checkbox 'Remove user settings' and placed it on ReadyToRemove dialog. Then I created a custom action specifying
cmd.exe /c rmdir /s/q "[AppDataFolder]MyProjectNameFolder" as File Name and Command Line param.
So, it removes MyProjectNameFolder if checkbox checked. But displays 'Error 1722. There's problem with this Windows Installer package....' when I'll trying to invoke this CA if c:\Users\username\AppData\Roaming\MyProjectNameFolder does not exist.
I have a question, what is the best approach in this case? Can installScript and DeleteDir function help me? Or may be it's better do not create InstallScript CA at all, but find correct condition for my Custom Action with cmd and rmdir?
[CODE]cmd.exe /c rmdir /s/q "[AppDataFolder]MyProjectNameFolder" >NUL 2>&1[/CODE]
HTH
It didn't help.I just tried to invoke rmdir with >NUL 2>&1 in the end using windows command line - it works (I mean it doesn't show me a message 'system cannot find the file specified').
But the same command in Installshield's Custom Action
[CODE]cmd.exe /c rmdir /s/q "[AppDataFolder]MyProjectNameFolder" >NUL 2>&1[/CODE]
still shows me an error dialog when I'm trying to delete folder that does not exist!
So, what's wrong here? Any other ideas?
[CODE]cmd.exe /c if exist "[AppDataFolder]MyProjectNameFolder" rmdir /s /q "[AppDataFolder]MyProjectNameFolder"[/CODE]
http://msdn.microsoft.com/en-us/library/aa371201(v=vs.85).aspx
Add two items into RemoveFile table, remove files and empty folder.
function Removefolder(hMSI)
STRING szPath;
NUMBER supportDirPathBuffer, nReturn, nvResult;
begin
supportDirPathBuffer = MAX_PATH;
MsiGetProperty(hMSI, "CustomActionData", szPath, supportDirPathBuffer);
nReturn = DeleteDir (szPath, ALLCONTENTS);
if (nReturn = 0) then
SprintfMsiLog ( "deleted folder: ",szPath);
else
SprintfMsiLog ( "Unable to delete folder: %s ; error %d",szPath, nReturn );
endif;
end;