Best Practice User Files and Folders in AppData - installation

I’m writing an application that should save user specific data into AppData. This application has an installer. Now I’m not sure, what is the best way to provide the folders in AppData.
Should the installer create (and delete) the folders, or should the application itself create (but probably never delete) the folders.
Also, if multiple user on the same computer use the app, the folders probably doesn’t exist, if another user installed the application.
I didn’t found anything that really explained this to me.
Thanks in advance.

I'll answer for Windows Installer, MSI files, and basically you shouldn't need to worry about it in the installer; just install files to their required locations, and the folder will be created automatically and removed at uninstall if it's empty.

In addition to Phil's correct answer:
If the files from the AppData folders used by your application are created only by the application, at run time, there is no need to configure the installer to create the empty folders. Those folders will be created the moment your app writes down the files.
Also, even if your installer is creating the folder, on uninstall it will not remove if in that folder are files created by the application. Windows Installer keeps track (should do it in a correctly configured package) of every file it installs and only removes the ones it installed (by default, it can be configured to force remove a folder and files which it did not install).
Regarding other users of the app. In this scenario, the simplest method is to use your application for creating the initial default files in the AppData folder, at the first launch of the app for each user.
If you need to install files to AppData from your installer then you could try one of the following approaches. These techniques can be applied with any setup authoring tool that can create MSI packages.

Related

How to change install location of msix bundle?

I have a WPF app that I am planning on deploying with the Windows Application Packaging Project in Visual Studio that makes the MSIX bundle for installations and future updates. The installer automatically installs the app in C:\Program Files\WindowsApps. This is fine until the program needs to cache some data or it needs to modify the appsettings file since the app does not have permission to get to these resources.
Is there a setting I can change in the packaging properties/manifest so it can install somewhere else so I can avoid these problems?
Indeed, only the Windows can write in %ProgramFiles%\WindowsApps when installing the msix package (by design). If your app is writing log files or other data inside the installation folder it will crash.
You need to either update your code to write to %AppData% or, if you don’t have access to the code, use the Package Support Framework to fix it. You can read more about here:
Package Support Framework (aka PSF)
The PSF brings support for API redirection and hooking. Thus, you can fix an app that failed to write a file in the installation folder (this is no longer allowed) and redirects it to a recommended location, or maybe simply update the app’s working directory.
As mentioned above, you cannot write in the install location of an MSIX package - this is by design.
For apps that are no longer under active developer indeed using the Packafe Support Framework is the only way to fix them. However, from what I see you are preparing to launch the app, so you have access to its code.
In this scenario, it is recommended you save all your app settings in the AppData\Roaming folder. For apps deployed as MSIX Windows will automatically redirect it under the Packages folder, but that is handled automatically by the OS, so you don't need to worry about it. More details below.
How to save data under AppData\Roaming instead of AppData\Local\Packages

installshield Installer deletes folder from my documents

I have two installers, one will create folder("ProjectRDE") in mydocuments using Installshield Limited Edition --> Application Files --> [PersonalFolder]. As expected when i run the exe, it created "ProjectRDE" folder in MyDocuments.
Another installer(which is also installs the same project output) will not have any folders in [PersonalFolder].(i consider the second installer as Upgrader.exe)
When i execute the second installer it deleted the "ProjectRDE" folder from MyDocuments. But i have not create any custom actions. Even I cant mark the folder as "Permanant", as the installer is only limited edition.
My query is, why this "ProjectRDE" is getting deleted, even i have not mentioned it in the second installer.
I'm not sure I exactly understand your situation entirely, but if your "Upgrader.exe" is actually performing a major upgrade, then it triggers an uninstall of the previous version, before installing the upgrade.

.ini file not being modified/updated when doing an upgrade with installshield since some folders are not being deleted when upgrading

Not too long ago I got a new job working on a tool that the company created to make people's lives easier when working on AWR.
I have successfully done multiple fixes and improvements which I was able to distribute via HotFix installers (simply overwrite the files that are already there).
My latest change/addition to the tool requires I create a complete installer for the tool. This particular tool always installs 2 versions, the current/new and the previous/old, to give a smoother transition to users. I have never done an installer before so I am learning as I go.
I was able to create an installer using the previous installshield project by simply updating/adding/removing files and folders. This works great when there is no version of the tool installed on the computer and there are no files/folders of any version of it on the installation locations.
I looked online and found that to make an installer that will install over a previous version I would need to do a major upgrade with installshield, which I did do after reading that. Now the installer successfully installs over the old version, it successfully places the new files and folders on their locations but always leaves one particular empty folder behind, the one for the 1.1.1 version.
That didn't seem like a problem until I realized that the .exe failed to modify the .ini file that it needs to modify to let AWR know where to look for the scripts. I looked through the .exe code and after running some tests, running it alone, I realized the .exe is not the problem, it does the job correctly. After doing many tests I found that as long as those empty folders exist the .ini files cannot be modified. I have no clue why since the .ini file is pretty much a .txt file and it makes no sense for there to be some sort of dependency on the 1.1.1 folder.
So my problem is one of two, either I have to figure out a way to make sure that the upgrade deletes those 1.1.1 folders or find a way to modify the .ini files with those folders still there. I have looked online and every solution requires me/the user to manually do something and I am being asked to make the installer simply work when used. They are asking me to make it so the installer takes care of everything and the user should not do anything except run the installer.
Since the installer works correctly as long as those folders are not there I figured making sure the installer removes them is the best way but I am stuck and I do not know how to proceed.
Thank you for any advice and help you can provide with this issue.
Solution:
Deleted all files I needed to make sure were updated from the components list and re-added them to the installshield project.
Since doing that everything was updated correctly and the folders were removed since the .exe was the correct one.

Rational Application Developer / Websphere polluting home directory

When I installed RAD with Websphere 7.0, I got a slew of folders created in my home directory:
%USERPROFILE%\IBM
%USERPROFILE%\Logs
%USERPROFILE%\PMT
%USERPROFILE%\updilogs
%USERPROFILE%\waslogs
%USERPROFILE%\web2feplogs
I am using Windows 7, so I actually use my home directory for various things, and hate that I have all these folders polluting my home directory (more than half of which are sitting empty).
Which of these can I delete? If RAD/Websphere need the directories, is there any way I can configure RAD/Websphere to have them to where they're supposed to be (that is, under %USERPORFILE%\AppData)?
(And I have hidden files/folders showing for work-related reasons, so I can't just hide them)
OK, so:
The %USERPROFILE%\IBM directory is the default directory for RAD to create new workspaces in. I am guessing that this directory was created when you first invoked RAD and it asked you where you would like a workspace created. Check the contents of that directory. If it only contains RAD workspaces, you can delete it (or move the individual workspace directories elsewhere).
I am not aware of a %USERPROFILE%\Logs directory created by wither RAD or WebSphere. Can you list some of the directory's contents?
The %USERPROFILE%\PMT directory wouldn't have been created by WebSphere or RAD. PMT stands for Profile Management Tool - a GUI that WebSphere provides for managing WebSphere profiles. Can you list some of the directory's contents?
%USERPROFILE%\updilogs are logs created by the installer of the WebSphere Update Installer (read that again). You cannot override it. You can delete this directory.
%USERPROFILE%\waslogs are logs created by the installer of WAS itself. You cannot override it. You can delete this directory.
%USERPROFILE%\web2feplogs are logs created by the installer of the WAS Web 2.0 Feature Pack. You cannot override it. You can delete this directory.
EDIT as per comment: The PMT\workspace directory seems to be of the format of an Eclipse workspace. I suspect this one was created when you (or a program that you ran) fired up the Profile Management Tool in GUI mode. As far as I know, this directory can be deleted but it will resurface next time you run PMT in GUI mode.

How to delete application file from AppData\Roaming folder

I am using windows installer to create setup project.
How I can remove/delete application files from AppData\Roaming folder when application uninstalled.
I tried added a special folder and set DefaultLocaltion to [AppDataFolder] but it didn't working.
Do I need to do anything else?
I'd need to understand what you are trying to do to give you specific advice. In general what you are trying to do would be OK removing files from CommonAppDataFolder but not AppDataFolder as trying to clanup user data from multiple user profiles is not a best practice. Additionally trying to cleanup Roaming Profile User data is outright impossible because the other users aren't logged on.
You'll want to read:
Managing Roaming User Data Deployment Guide
Assuming you are trying to do what I think you are, you'll need a cleanup script / exe that you leave behind on uninstall and a custom action to write to the registry during uninstall ( MSI can't do this natively ) to call that script/EXE. You'll want to leverage the Active Setup trick as described here:
Using Active Setup to Repair User Settings
The way it'll work is your uninstall leaves the EXE and registry entry behind so that when a user logs on it's roaming data gets pulled down from the server to local and Active Setup realizes it hasn't run the script yet. The script runs (once) and the data is deleted. When the user logs off the data is replicated / deleted on the server. Then they log on again it doesn't run again.
By default Windows Installer does not remove the files created by your application, after the installation. To do that you need to either write your own custom action, that will run upon uninstall, or depending on the tool used for authoring the MSI, you can use built-in options for cleaning the application locations, as some tools have this support.

Resources