views:

22

answers:

1

The users that will be installing and using the application I created may not have to access to the Program Files folder. Therefore, my boss and I thought it best that we put the SQLite database in a public location, but not the desktop. We were thinking of the Application Data folder on the All Users profile, but when I got to my other computer, I realized that the OS of the computer could be either XP or Vista and higher. Therefore, I need my database folder to change based on version. When in the File System view for the setup project, it naturally has an Application Folder ([ProgramFilesFolder][Manufacturer]\[ProductName]), User's Desktop (DesktopFolder), and User's Programs Menu (ProgramMenuFolder). Is there any shortcut name for the Public/All users folder? I'm unable to find one and while I know I could make two separate installations rather easily, I am just curious to know if there's a way to do it this way. I already have some if statements in my code to determine where to look, I just have to figure it out now in the setup project. Thanks.

A: 

There are "variables" you can use, hardcoding paths is a no-no

Onkelborg
Yeah, I know, that's why I was wondering if there's a variable that can be used on XP and earlier and Vista and later. Something like "CommonUserFolder" which would determine at the time of installation which folder structure to use.
XstreamINsanity
Hm, why don't you want the same folder on both XP and Vista? Don't you want the AppData-folder for all users independent of operatingsystem?
Onkelborg
In XP and earlier, it's C:\Documents and Settings\All Users\Application Data\.... For Vista, it's C:\Users\Public. When I create the custom folder in the File System of the Setup Project, it has a spot in the Properties Window for Default Location. You have to put a path there. Unfortunately, I cannot find a variable name for the "All Users" or "Public" folder. If I could do [CommonUsersFolder] and that would go to either All Users or Public, then that'd be great, but I can't find one.
XstreamINsanity
Yes, I want the same folder, however, because of the policies, I can't just specify a folder and tell our client to make that folder accessible by all people. It's something that already has to be accessible to all people. The only folder we believe that to be is the All Users folder (or Public).
XstreamINsanity
There's an environment variable called %allusersprofile%, can you use that one?
Onkelborg
By the way, you really shouldn't rely on the fact that you run on a specific operating system, here in Sweden, on swedish Windows XP, what you know as "c:\program files" is here known as "c:\program". And I have my c:\Users located on d:\.. ;)
Onkelborg
:) Yeah, I can understand that. However, this program will only be used in the US since it's for our customer and they only use one version of OS. But that is good knowledge for me to keep around when I develop my own apps. I don't see an environment variable called %allusersprofile% on my machine, but I'll look into it. How would I put that into the properties window of the Setup application?
XstreamINsanity
Also, I'm not sure if that environment variable would translate to Vista and beyond. Currently, my boss just said to go with the Vista format and later, and if we run into it, which he doubts we will, we'll worry about it then. Thanks.
XstreamINsanity
Hm, I have that environment variable on both an XP machine and on my Win 7 machine. Try; open cmd and run (without quotes): "echo %allusersprofile%"
Onkelborg
On my work machine, that returns "C:\ProgramData" I'm not sure if that is going to be accessible to the users though. I'll have to ask around. And that's on a Vista machine.
XstreamINsanity
That's correct, but most likely, you don't have write access there
Onkelborg
I may try to use one of <a href="http://msdn.microsoft.com/en-us/library/bb762584%28VS.85%29.aspx">these</a> (echo %public%) since when I used it it came out with "C:\Users\Public". I need to test it on my XP machine at the other office though. However, in the Properties window, should I put %public%, [Public] or [%Public%]?
XstreamINsanity
%public% seems to be new for Window Vista though.. :/
Onkelborg