I have a program and a windows service located in the same folder. They could be run under different user accounts. Will they be always able to write to the folder where their .exe are located or this still depends on the rights of a particular account they run under? If not then what folder can I use for sharing common data amoung them?
No. In general, executables are installed in \Program Files\ (CSIDL_PROGRAM_FILES). You need a program-specific subdirectory under CSIDL_COMMON_APPDATA. (Create this subdirectory with appropriate ACL's for your situation).
In most cases (i.e. for most kinds of accounts which are not Administrators) the application (or the service) won't be able to write to \Program Files folder if it has been installed there (as it's done by default).
To share the data between applications you can use FOLDERID_ProgramData folder and get it's path using SHGetFolderPath.
Related
We have a Windows application with a component that writes to the ProgramData folder. When the uninstaller is run, the files that are generated by this component are not removed. Using UAC::RunElevated, we first install a third party component into ProgramData
SetOutPath "$RENDERER_INSTALL_DIR"
LogSet On
File /r "${MAGNIFY_DIR}/secRenderer/Arelle/*"
LogSet Off
AccessControl::GrantOnFile "$RENDERER_INSTALL_DIR" "(S-1-5-32-545)" "FullAccess"
During operation, this component writes to its own install directory in ProgramData
During uninstallation, we attempt to delete the folder created above, again using UAC::RunElevated
RMDir /r $RENDERER_INSTALL_DIR
However, the files created by operating the component are not removed.
We have observed that these files are owned by the user who used the component, rather than the Administrator, who nonetheless has full read, write and delete permissions.
How do we make this work?
There are two many unknowns here to really answer the question.
Why is the UAC plug-in involved? It is only useful to lower your system access! It is also tricky to use correctly so I would recommend that you try without it.
Does this 3rd-party component change the ACL? Check the ACL before uninstalling.
Is it possible that file system virtualization is tricking you? Check the VirtualStore folder.
What does Process Monitor say? Are you getting ACCESS_DENIED or some other error?
Giving all users full access to folders under ProgramData is not recommended and any component that requires this does not follow the Windows Logo guidelines.
I have written a Visual Basic.Net application in Visual Studio 2012 Ultimate. When this application is installed to the Program Files folder, when files are saved, they are located in this location:
C:\Users\[Username]\AppData\Local\VirtualStore\Program Files\[Company Name]\\[Application Name]
How can I specify to save the files in the following directory:
C:\Users\[Username]\AppData\[Company Name]\\[Application Name]
folder (basically, not the VirtualStore folder)?
Do I need to register this application within Windows to do this?
Thanks in advance
First, what instalation software are you using?
Second, if you're going to save your app files in the AppData directory, then you should really choose to save your app in either the, Roaming, Local, or LowLocal directory. It isn't "proper" to start making new directories where other directories are available to use, especially since the Roaming, Local, and LowLocal directories were more-or-less made to hold application's data (which is why the parent directory is call "AppData").
I am creating a WIX installer project. During one managed customized action, I need to create a file (other than the deployed files specified in the components of WIX) in the installation folder, which by default is the Program Files folder. I am experiencing the "Access denied" problem in Windows 7. After some searching, I found out that people say it is not advisable to create files into Program Files folder. Instead, try to create files into for example AppData folder. For example, see this link:
C# Access denied to path in a Windows Application
But my question is, the generated file is crucial to our SW, so it must reside in the installation folder. Isn't it the target of SW installation, I mean, to create file in most of the cases Program Files folder? Does it mean the only files should be added into installation folder, during the installation, are the deployed files (basically the targets of XCopy)?
My file can't be made deploy-able in the WIX, i.e, it can't be made ready before the installation. So what's the proper way or best practice to handle such situation: a file must be generated during the installation, into the installation folder. It is not some log file that I can put somewhere else. I tried to create a Permission element in WIX for the INSTALLADIR, although it seems to be against the rule mentioned in the link, but it still failed. Thanks!
UPDATE:
Based one MichaelUrman's commen, some more information. The generated file is needed after the SW is installed and necessary during normal launch of the SW. And I think it needs to be modified during normal use after the installation. And as I mentioned my a comment to #caveman_dick answer, my CA is actually in commit phase, I don't know whether there is any difference between it and normal deferred CA
Set the custom action to Execute="deferred", that will run the command elevated and should give it the required permissions to create the file.
Since you need to update that file from the main application, and I'm assuming your application does not require elevated privileges, you have three options.
The first is the worst: without a manifest, your executable's attempts to write to the Program Files folder will typically result in it being redirected to the Virtual Store (see File Virtualization). It sounds like this isn't happening in your case, so you can't use it.
The second option is to modify the application to store this in an appropriate location such as the ProgramData folder, or Common Documents, or (if appropriate) a per-user location under LocalAppData. This is typically the best approach, but has the highest development costs.
Finally the third option is to create the file and change its permissions (or in some cases to change the permissions on the folder containing the file), allowing limited users to modify this file. See LockPermissions or MsiLockPermissionsEx for the Windows Installer way to approach this. Change the permissions on as few files or folders, as restricted as possible, to keep the system as safe as possible if you go with this option.
The default installation location of our applications is c:\Program Files folder. Due to virtulization, this is not a good location to install our applications in 'Program Files' folder in Windows 7. What is the preferred default installation location in Windows 7..
Does microsoft say specify anything on this?
Where can I get more information on this?
Our application can create projects which are kept in c:\Program Files\PolyCd\Projects folder. User can copy these files to other machines to use the project files. We also don't want to run the application as administrator to avoid prompting whenever the application starts. This enables virtualizations. And hence the user won't be able to see the project files he created in c:\Program Files\PolyCd\Projects folder
I have one more question. What is the preferred location of keeping the application specific data such as the project information I mentioned earlier
Ah, thanks for the clarification. Your problem is where you are storing the data. Generally, settings and the likes should be stored in the folder specified by the environment variable AppData. Project data, documents, etc however should generally be stored in the user's "Documents" folder.
'Program Files' or 'Program Files (x86)' for 32-bit software on 64-bit Windows. But you would usually use a variable like $PROGRAMFILES so Windows finds the folder itself.
Since you asked specifically "does Microsoft say anything on this?" let me show you the Windows logo requirements from Microsoft. After you download that document, you can read guidance that includes what folder to install to (Program Files) and where to keep the user's data and settings (ProgramData or AppData). If you follow these guidelines, not only will your application behave as users expect, you will find it easy to get the Windows Logo for your application, which is a shortcut into the partner program. Many of my clients save tends of thousands of dollars on software by being in the partner program, so don't dismiss the value of the logo. But the immediate value to you is clear direction about where to put your app and where to put the user's data.
If I use the publish feature in VS2008 (I think it's called ClickOnce install), and then install the published application in another computer, where are the files copied?
In other words: If I need an auxiliary file (a .txt file) in the same path of the assembly, where do I have to create it?
Thank you.
You should have specified the location when you published the application. Just note down that folder.
If you run the wizard again for the same project it should have remembered the location and the folder will be pre-filled on the form.
I've used this and I specified a location on my hard drive for the Publishing Folder Location. This folder contains the following files:
publish.htm
setup.exe
[application].application
It also contains a folder called Application Files which contains the files needed to build the installation - the exe, the manifest, other dlls and external resources.
I then copy the three files and the folder to the web location specified by the Installation Folder URL.
If you're talking about where the files get installed to then they're in:
C:\Documents and Settings\[user]\Local Settings\Apps\2.0\H165QZM1.QBE\0OAEZTRX.Y3N\[some truncated version of the exe name followed by a GUID]
Which isn't the most obvious place. I should also point out that the folders H165QZM1.QBE and 0OAEZTRX.Y3N will probably be different on different machines, but the only other folder under C:\Documents and Settings\[user]\Local Settings\Apps\2.0 is called Data so they should be easy to spot.
Is the application available offline or online only? My experience is online only and in that case I believe it installs into a temp directory. Can you include your auxiliary file as part of the application files? This may help as well it talks about including data files which can be of any type.
http://msdn.microsoft.com/en-us/library/d8saf4wy.aspx
http://msdn.microsoft.com/en-us/library/6fehc36e.aspx