This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Remove folder in AppDataFolder during Uninstall
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 16, 2013
09:54 AM
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?
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?
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 16, 2013
03:26 PM
Maybe this would help - it pipes all output it to NUL so it doesn't care if it does or does not find the folder. It also wouldn't care if it found the folder but couldn't delete it, though.
[CODE]cmd.exe /c rmdir /s/q "[AppDataFolder]MyProjectNameFolder" >NUL 2>&1[/CODE]
HTH
[CODE]cmd.exe /c rmdir /s/q "[AppDataFolder]MyProjectNameFolder" >NUL 2>&1[/CODE]
HTH
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 18, 2013
03:09 AM
ch_eng,
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?
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?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 18, 2013
05:20 AM
Do this instead. It only executes the rmdir if the destination exists. This way you will still see other relevant error messages if you do get a real error.
[CODE]cmd.exe /c if exist "[AppDataFolder]MyProjectNameFolder" rmdir /s /q "[AppDataFolder]MyProjectNameFolder"[/CODE]
[CODE]cmd.exe /c if exist "[AppDataFolder]MyProjectNameFolder" rmdir /s /q "[AppDataFolder]MyProjectNameFolder"[/CODE]
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)
Not applicable
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 18, 2013
11:41 PM
If you project type is Basic MSI, you can delete these files through RemoveFile table.
http://msdn.microsoft.com/en-us/library/aa371201(v=vs.85).aspx
Add two items into RemoveFile table, remove files and empty folder.
http://msdn.microsoft.com/en-us/library/aa371201(v=vs.85).aspx
Add two items into RemoveFile table, remove files and empty folder.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 19, 2013
08:30 AM
Im Using a custum action like
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;
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;
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)